English 中文(简体)
如何在利用Jquery进行最后一次冲撞之前获得价值
原标题:How to get value before last forward slash using Jquery
  • 时间:2011-09-29 10:35:57
  •  标签:
  • jquery

I ha got these types of hrefs

http://localhost:8080/en/reservations/tours-and-safaris-booking-enquiry-form/dubai/index.aspx
http://localhost:8080/en/reservations/tours-and-safaris-booking-enquiry-form/muscat/index.aspx

现在,我需要写一份职能,把这一职能作为投入,并将回到“旅游和沙法斯-书购-购物”。

请建议!

最佳回答

你们可以做主分立(一阵)并获得第二至最后部分。

var _array = url.split( / ),
    _foo = _array[_array.length-2];

你们必须注意以这种方式编排的URLs:

http://your.domain.com/path/to/something/

......也就是说,那些有前线冲撞的人群,因为他们最终会形成一个空洞的阵容(可以 throw掉你的 par)。 你们可能首先想取消空洞元素,然后才能恢复你真正想要的特性(使用)。 这一解决办法

问题回答

如果你将始终如此严格(即总是在你想要的那部分之前有同样的编号/的特性),那么你可以这样做:

var partYouWant = yourString.split("/")[5];

<https://developer.mozilla.org/en/Java/Reference/Global_Objects/String/split” rel=“nofollow”>split。 回归一阵列,而你想要的那部分是指数5。

请注意,贵格会不会帮助你。 你想要的老大 Java。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签