English 中文(简体)
与j Query的管道
原标题:truncate links with jQuery
  • 时间:2012-01-12 09:54:39
  •  标签:
  • jquery

我的第一个职位在这里,但我已经学到很多东西。 此时此刻,我无法找到解决问题的办法,尽管它看起来像一件容易实现的事情。

我有一份与Fed2JS公司制作的博客链接清单。 不幸的是,作为这一来源的RSS为我不希望的联系增添了基础。 我可以改变饲料,因为它自动产生于快速的Weaver。

是否有可能把 everything中的一切东西从 has中去掉? 例如:变化

http://www.example.com/blog/ files.398e042ea42b7ee9d1678b3c53132fc3-31.pdf

纽约总部

rel=“nofollow”http://www.example.com/blog/files/398e042ea42b7ee9d1678b3c53132fc3-31.php

I m pretty new 纽约总部 jQuery, and still have a lot 纽约总部 learn, so please keep your answer simple.

Jeroen

问题回答

确保你能够做这样的事情:

var str =  http://www.example.com/blog/files/398e042ea42b7ee9d1678b3c53132fc3-31.php#unique-entry-id-31 ;
var substr = str.split( # );
// substr[0] contains "http://www.example.com/blog/files/398e042ea42b7ee9d1678b3c53132fc3-31.php"
// substr[1] contains "unique-entry-id-31"

请注意,这是来自 Java普森的版本。

你们不需要为此而利用 j:

function truncate(href) {
  var a = document.createElement( a );
  a.setAttribute( href , href);

  a.hash =   ;
  return a.href;
}
var url = "http://www.example.com/blog/files/398e042ea42b7ee9d1678b3c53132fc3-31.phpunique-entry-id-31";

alert(url.substring(0,url.indexOf( # ))); // will give you empty string if you dont have # in the url.

因此,你可以使用

alert(url.split( # )[0]);




相关问题
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: &...

热门标签