Add JS to children of element

Hello, I want to add JS (Jquery) click to this dynaSelect’s children neighbor. How can I make this without click, or doing any other actions to dynaSelect

<div class="col-md-6 dynaSelect">
  <div class="input-group addInput">
    <select class="sel">
      <option value="0">all categories</option>
      <option value="1">software</option>
      <option value="2">hardware</option>
      <option value="3">mechanical</option>
      <option value="4">HR/Manager</option>
    </select>
    <span class="input-group-addon neighbor">+</span>
  </div>
</div>

I’m confused - you want to add click, without click?

No, I want to add click to .neighbor element without clicking her parent .dynaSelect
using this.

Can you use the $(“.dynaSelect .neighbor”) selector?

For example,
$('.dynaSelect').click(function(){ $(this).find('.neighbor').click(function(){ //some code here }) });
But instead of $('.dynaSelect').click using another type of event

Why do you think that a click event on the neighbor element, would result in a click event happening on dynaSelect?

I have 2 dynaSelect on my project. I want to add click event their own neighbor element

That happens, doesn’t it, with the following?

$(".dynaSelect .neighbor").on("click", function (evt) {
  ...
});

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.