English 中文(简体)
Jquery: 选择“DIV ID”和“LI CLASS”和“LINK”案文
原标题:Jquery: select "DIV ID" and "LI CLASS" and "LINK" text

我愿选择“#container” active>,并添加a> tags textlink here> > 至一个变量及其标志。

  <div id="container">
        <div id="head"></div>
        <div id="body"></div>
        <ul>
            <li class="item active">
                 <a class="link">link here</a>
            </li>
            <li class="item"></li>
            <li class="item"></li>
            <li class="item"></li>
        </ul>
    </div>

我的法典迄今为止就是这样,......根本看不到问题。

var tabid = $( #container.active a ).text();
console.log(tabid);

感谢一切帮助! 和平不前。

最佳回答

Your code is missing a space. use:

$( #container .active a )

or better, if your html structure stays the same:

$( #container > ul > li.active > a )

并且,你们必须保证,在人力部准备就绪之后,你们的法典得到执行:

$(document).ready(function () {

var text = $( #container > ul > li.active > a ).text();
console.log(text);

});
问题回答

引言

$( #container .active a ).text();

在<代码>之前添加一个空间。

http://jsfiddle.net/w5U8Q/“rel=“nofollow” http://jsfiddle.net/w5U8Q/。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签