Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting text of li

I have made list:

<ul>
<li id="one"></li>
</ul>

And then in jQuery I do:

 $("#one").text("one");

However it is not changing, also I have tried using .val() but it didn't help.

Why it happens and how to change the li text?

like image 941
maximus Avatar asked Jun 19 '13 11:06

maximus


1 Answers

There may be one of the problem you have

1) You did not imported js files properly

2)You might not write the code in ready function

Write your code in ready function and import jQuery related js files.

$( document ).ready(function() {
    $("#one").text("one");
});

http://jsfiddle.net/zBxTm/

like image 130
PSR Avatar answered Sep 30 '22 19:09

PSR