2

What I'm trying to do is disable the link. How to disable link if dropdown select value was change?

If I select add in dropdown, edit and remove link should be disable. Help?

<select id="">
<option value="add" selected="selected">Add</option>
<option value="edit">Edit</option>
<option value="delete">Delete</option>
</select>

  <a class="button add" style="cursor:pointer;"><span><b>Add Purchase Request</b></span></a>
  <a class="button edit" style="cursor:pointer;"><span><b>Edit Purchase Request</b></span></a>
  <a class="button remove" style="cursor:pointer;" name="remove"><span><b>Remove Purchase Request</b></span></a> 
user3318208
  • 93
  • 1
  • 5
  • 19

2 Answers2

2

Try this,

$('select').change(function () {
    var va = $(this).val();
    if(va=='add'){
      $('.remove').attr('disabled', 'disabled');
    }
    else{
        $('.remove').removeAttr('disabled');
    }
});
Roshna
  • 206
  • 2
  • 10
0

You can hide your anchors based on the selected option instead:

$('select').change(function () {
    var index = $(this).find('option:selected').index();
    $('a.button').eq(index).show().siblings('a').hide();
}).change();

Fiddle Demo

Felix
  • 37,892
  • 8
  • 43
  • 55