English 中文(简体)
jquery ul li selectedor
原标题:jquery ul li selector

名单

<ul style="display:none">
  <li id="key1" title="Look, a tool tip!">item1 with key and tooltip
  <li id="key2" class="selected">item2: selected on init
  <li id="key3" class="folder">Folder with some children
    <ul>
      <li id="key3.1">Sub-item 3.1
      <li id="key3.2">Sub-item 3.2
    </ul>

  <li id="key4" class="expanded">Document with some children (expanded on init)
    <ul>
      <li id="key4.1">Sub-item 4.1
      <li id="key4.2">Sub-item 4.2
    </ul>
</ul>

是否有办法选择每一带; 是否通过“id”和询问来选择。

我试图这样做,但现在却在工作。

$("ul li:#key1").qtip({
         content:  <img src="icons/Icon.png" /> 
    });

回答的标语是,但上述内容都没有奏效。 我试图这样做。

$("ul li:first").qtip({
 content:  <img src="icons/Icon.png" /> 
});

and im able to see the qtip.But only f或 the first on the list (key1). Trying

$("ul li#key1").qtip({
 content:  <img src="icons/Icon.png" /> 
});

$("#key1").qtip({
 content:  <img src="icons/Icon.png" /> 
});

its not w或king f或 me.. =/

问题回答

Just use a id 选择:

$("#key1").qtip(...);

<代码>id Value must 在网页上是独一无二的,因此,将其他所有细列的斜线放在<代码><>jQuery use document.getElementByID, 而选择器是ice,简单(例如,快捷)加以 par和应用。 (当然,如果您希望挑选人填写key1。) 页: 1 但通常这并非你想要的东西。

请注意,您的一些<代码>id 数值将需要放弃,因为您有<代码>。 为躲避“.,请在选任人面前lash击。 由于遴选人处于 Java的座右铭,你不得不逃避冲锋,以实际上将斜坡冲进选人,因此,你使用两条:

$("#key4\.1").qtip(...);

为什么额外上校<代码>:? 你非常需要。

$("ul li#key1").qtip({
     content:  <img src="icons/Icon.png" /> 
});

是的。

$("ul li#key1").qtip(); //rest of code

而且,由于这是一个身份证,而且很可能是独特的。 你们只能使用:

$("#key1")

If you are selecting by id, there is no need to specify the type, class or parent class. IDs should be unique.

举例来说,如果你想共同选择其中的钥匙1、钥匙2和钥匙3,你可以使用以下挑选人:

$("#key1, #key2, #key3").qtip({
         content:  <img src="icons/Icon.png" /> 
    });

或以下列一种方式选择:

$("#key1").qtip({
         content:  <img src="icons/Icon.png" /> 
    });

$("#key2").qtip({
         content:  <img src="icons/Icon.png" /> 
    });

或者,你可以做这样的事情,具体列出关键人物名单,而不是重复选择和初步选择qtip:

var keys = [ key1 ,  key2 ,  key3 ];

$(keys).each(function(i, key) {
    $("#" + key).qtip({
         content:  <img src="icons/Icon.png" /> 
    });

});




相关问题
Marking up an ordered list to start at point after 1

So, according the W3C spec, the start attribute in an ordered list is deprecated. If you want to continue a list that s been broken up by a series of heading, you might have: <ol start="15"> ...

How to check if a list is ordered?

I am doing some unit tests and I want to know if there s any way to test if a list is ordered by a property of the objects it contains. Right now I am doing it this way but I don t like it, I want a ...

Is div inside list allowed? [duplicate]

I know that DIV inside LI isn t allowed, but I ve seen it lately on many "big" websites like Smashing Magazine, Web Designer Wall... etc. I tried to validate sites, and they have errors, but nothing ...

Center an unordered list in a table

I have code like this: <table> <tr> <td align="center"> <ul> <li style="float:left;display:inline">Some text</li> <li style="float:...

Having line breaks between <li>s

I have a horizontal menu consisting of <li> elements with display: inline. The elements are supposed to be next to each other seamlessly. In the source code, I would like to have each li on ...

PHP Array to List

How do I go from this multidimensional array: Array ( [Camden Town] => Array ( [0] => La Dominican [1] => A Lounge ), [Coastal] => Array ( [0] => Royal Hotel ), ...

热门标签