Pierreszwk Pierreszwk - 1 year ago 72
CSS Question

Put li attribut on a span

I am a beginner in the wonderful world of dev and I need help from you. Let me explain :

I have a menu that deploys when pressing on the burger and thus reveals three items .
On the one hand I am that when you click on an item the menu closes
And on the other hand I am cut the item to appear in the SPAN :)

$('li').click(function() { alert($(this).attr('id'));})

Thank you for your help.

Envoy Everybody

Answer Source

simple as this : jsfiddle

added this

 $('li').click(function() {
   $('h1 + span').text( $(this).attr('id') )

also removed the class open from #overlay so after you click the li the menu closes, and removed the class active from the button so it changes from X to the hamburger lines . you can exclude these two lines if you don't need them

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download