Reputation: 32321
I have a HTML as shown above
<div id="restmenu" class="restMenu">
<ul>
<section id="4" addlabel="Office" class="ulseWrap lielement">
<div class="intit someclassss activeRest ">Office<span id="deleteOffice" class="inDelete"></span><span class="inEdit" title="Modify Address" name="Modify Address"></span></div>
</section>
</ul>
</div>
When clicked on lielement , i am getting response from the server and adding this particular lielemnt
Right now i am doing this way .
$("#restmenu").find('#'+locationname).append(ulhtml);
By default this is finding id .
Is it possible to find the addlabel
attribute and add data to it ??
Means i need to find out the "Office" and add this data to it .
Upvotes: 0
Views: 59
Reputation: 28513
Yes, it is possible to append using attribute addlabel
$("#restmenu").find('section[addlabel="Office"]').append(ulhtml);
NOTE - Please make sure that id
s must be unique through out the document
EDIT - As OP wants addlabel
value dynamic, below is the code
Use some variable to store addlabel
value and concatenate it in jQuery selector as shown below -
var locationName = "Office";// location name
$("#restmenu").find('section[addlabel="'+ locationName +'"]').append(ulhtml);
Upvotes: 2
Reputation: 1287
Try this for dynamic
locationName :-
$("#restmenu").find('section[addlabel="'+locationName+'"]').append(ulhtml)
Upvotes: 0