Behseini Behseini - 1 year ago 74
Javascript Question

Having Issue On Selectiong a Dom Target with jQuery Traversing

I am trying to update the content of

dynamically with using jQuery but not sure why I am not able to target the
I know that we can simply use
but as I said I need to do this through jQuery Traversing mechanism like using following
but none of them did the job!


$(".dropdown-menu li a").click(function(){


<script src=""></script>
<div class="col-md-6">
<div class="form-group">
<div class="col-md-12">
<label class="control-label" for="new-cu-emailinput"></label>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="selector" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Please Select From the List<i class="fa fa-chevron-right pull-right" aria-hidden="true"></i></button>
<ul class="dropdown-menu" aria-labelledby="selector">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Separated link</a></li>

<span class="help-block pull-right"></span>


Can you please let me know what I am doing wrong?

Answer Source

Your selectors are wrong. Try like following.

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