I have this jQuery code that I am using to create a dynamic menu
function createList(test){
alert(test);
$('#nav')
.append('<li class="top"><a href="nogo2" id="products" class="top_link"><span class="down"></span></a></li>');
$('.down').text(test);
}
the problem that I have is when I try to add the text to the span
$('.down').text(test);
the menu changes to whatever value is the last for example if my values are a b c d e then all my menus e e e e e can any body help me thanks
You can try using this to select only the last .down instead of all:
$('.down:last').text(test);
Why don't you do it directly like this:
function createList(test) {
alert(test);
$('#nav')
.append('<li class="top"><a href="nogo2" id="products" class="top_link"><span class="down">' + test + '</span></a></li>');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With