I am trying to append a li to only the UL which has a certain oid value set like this
$('ul.sortablespm oid=' + data).append('<li></li>');
It works fine without the oid parameter, but then adds the li to all ULs on the page..
I am trying to append a li to only the UL which has a certain oid value set like this
$('ul.sortablespm oid=' + data).append('<li></li>');
It works fine without the oid parameter, but then adds the li to all ULs on the page..
Here is a working example of what I believe you are looking for.
http://jsfiddle.net/chapmanc/wU6Vs/
If the ul object has a unique id you can simply use that as your selector and append an item to that object.
For example a ul with an id of myList:
<ul id="myList">
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
And a function to append to that object using the unique selector:
$('#myList').append('<li>d</li>');
This appends a li item to the myList object. Notice the '#' character in front of myList when using an id selector.
Use the appropriate attribute selector syntax, that is,
[name="value"]
: