English 中文(简体)
j 质量`是'不是职能
原标题:jQuery `is` is not a function
  • 时间:2012-01-12 11:50:14
  •  标签:
  • jquery

我有超文本。

<ul>
    <li><a href="index.html">Index Page</a></li>
    <li><a href="#some-page">Some Page</a></li>
</ul>

请允许我说,var url = “一页”;

    $( #menu li a ).prop( href )
                   .is( #  + url )
                   .parrent()
                   .addClass( active );

页: 1 并非职能。 为什么?.is显然是职能。

Any suggestion much appreciated.

最佳回答

The prop() method you are calling before is() is returning the href property as a string.

指令没有<代码>is()方法。

提审;

$( #menu li a ).filter( [href="  + url +  "] ).parent().addClass( active );

虽然你可以把这合并为一个挑选人;

$( #menu li a[href="  + url +  "] ).parent().addClass( active );

了解到is() Returncode>true or false,条件是对应内容的any与甄选人匹配;因此,如果您希望使用is(<>;

$( #menu li a ).each(function () {
    if ($(this).is( [href="#  + url + "] )) {
        $(this).parent().addClass( active );
    }
});

attribute。 平等:

问题回答

prop(),如果财产被设定或其价值,即truefalse<>/code>或 string-且无-method on a boolean or a string.





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

热门标签