Cosmin Manea Cosmin Manea - 1 year ago 86
HTML Question

Javascript : How to hide multiple generated div?

I have this

class="slip line_{{lineIndex}}
and its generating multiple divs with different numbers and i need a javascript to select a div with specific class.

<div id="tickett_" data-type="slip" data-slip-index="{{lineIndex}}" class="slip line_{{lineIndex}}" class="lottoroom_yourTicket-content_tickets" style="display: none;">

Answer Source

Try this jQuery selector:

$(".slip.line_" + lineIndex)

Note: to find an element with multiple CSS-classes use this format:


In your case if you don't have CSS-classes like 'line_{{lineIndex}}' in other places of your page you can just use the following selector to find required div:

$(".line_" + lineIndex)


$("div.line_" + lineIndex)

Update: Your HTML is incorrect:

class="slip line_{{lineIndex}}" class="lottoroom_yourTicket-content_tickets"

You have multiple class-attributes. You should combine them:

class="lottoroom_yourTicket-content_tickets slip line_{{lineIndex}}"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download