Welcome Guest, Not a member yet? Register   Sign In
how can we get dynamic ids of spans using jquery ?
#1

[eluser]Zeeshan Rasool[/eluser]
Dear User! Here is a issue i want to make slide toggle for categories which comes dynamically
on front page i want id so that i identify clicked span and slide up required panel so
Simple code is
Code:
$(".help_content5").click();
    $(".help_content5").hide();
    //toggle the componenet with class msg_body
    //
    $(".help_icon5").click(function(){
        $(this).next(".help_content5").slideToggle(250);
    });

Here i need to append id with a string like "help_content5" and 5 comes dynamicllay on click so plz any solution thru which we can get id

beacuse at this stage we dont know span id or some thing other to identify we are just appending an integer with spon as
Code:
<span class="help_icon'.$k.'" id="'.$k.'">

Thanks v much.
#2

[eluser]rogierb[/eluser]
You don't need the ID to reference the span, just use attributeStartsWith(attribute, value)

Code:
$("#span[class^='help_content'").click(function(){
$(this).hide();
    //toggle the componenet with class msg_body

})




Theme © iAndrew 2016 - Forum software by © MyBB