Richa
Richa

Reputation: 3289

Showing clicked li and hiding original

I have a drop down list consisting several item.

Now hat i want is when we click And a drop down appears. Now when we click on any option in dropdown, the original should get replaced by clicked.

For eg : Original is And, now in drop down if we click Not And, then And should get replaced by Not And and so on.

Can someone please me out with it.

Thanks

Upvotes: 1

Views: 67

Answers (2)

Felix
Felix

Reputation: 38112

You can use .html() to get and set the html content of an element:

$('.clicker li').click(function (e) {
    $('.clicker .hello').html($(this).html())
});

Fiddle Demo

Upvotes: 1

Arun P Johny
Arun P Johny

Reputation: 388406

Try

$('.click-nav .js ul li').click(function (e) {
    $(this).parent().prev().html($(this).html())
})

Demo: Fiddle

Upvotes: 4

Related Questions