简体   繁体   English

li元素内的文字

[英]text inside li element

im printing out unordered lists dynamically..something like this 我动态打印出无序列表..类似的东西

$sql2 = mysql_query("SELECT id, todo FROM todo");

while($row = mysql_fetch_array($sql2))
{
    $todo1 = $row["todo"];
    $todofeed.='

    <ul>
        <li>' . $todo1 . '</li>
    </ul>   

    ';
}

I want each li element that is printed out to be a link for some jQuery effect and for that I need the text inside each li element dynamically ie as and when i click on it.Any way around this? 我希望每个打印出的li元素都是一些jQuery效果的链接,为此,我需要动态地在每个li元素内输入文本,即当我单击它时。

Just add a class to your <ul> element so that you can access it with Jquery later on: 只需将一个类添加到您的<ul>元素中,以便稍后可以使用Jquery访问它:

...
$todofeed.='

<ul class="effective">
    <li>' . $todo1 . '</li>
...

With Jquery manipulate the DOM so that your link is added: 使用Jquery 操纵DOM,以便添加链接:

$('ul.effective li').wrapInner('<a ... />');

But you could also add the click/hover events on the li elements. 但是您也可以在li元素上添加click / hover事件 Do what suits you better, your question is not really specific, so hopefully this will give you some ideas. 做更适合您的事情,您的问题不是很具体,所以希望这会给您一些想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM