javascript - Dynamically remove select option value using href - jquery - Stack Overflow

I am having a list of users with delete hyperlink assume<a href="#" onclick="delete(i

I am having a list of users with delete hyperlink assume

<a href="#" onclick="delete(id)">Delete</a>

And i have a bo box at the top to filter specific user using user id.

The delete action will performed with ajax and it reloads the content. The content gets reloaded but the bo box contains the deleted id. Is there any way to clear it using jquery.

I am having a list of users with delete hyperlink assume

<a href="#" onclick="delete(id)">Delete</a>

And i have a bo box at the top to filter specific user using user id.

The delete action will performed with ajax and it reloads the content. The content gets reloaded but the bo box contains the deleted id. Is there any way to clear it using jquery.

Share Improve this question asked Aug 24, 2013 at 10:58 PrabhakaranPrabhakaran 4,01915 gold badges51 silver badges119 bronze badges 2
  • Please show us the code you have tried. – mishik Commented Aug 24, 2013 at 11:00
  • Please include your code, or just add it in jsfiddle and give us the link – Imane Fateh Commented Aug 24, 2013 at 11:01
Add a ment  | 

5 Answers 5

Reset to default 1

You can remove an option like

$("#selectBox option[value='option1']").remove();

Yes,If you know the value which you want to delete,

Try

$("#selectionid option[value='deletedUser']").remove();

Note:Do it in Ajax success function

You could try something like this:

    $(function delete(id) {
      $('#my-select option[value="'+ id +'"]').remove();
    });

Try this...

$( "#myselect option:selected" ).remove();  // because your deleted user id will be selected 

Here first you get the element in jQuery selector through id or class the find the option which you want to delete or remove.. like if first element then eq(0), if second then eq(1) and so on.. then remove function to remove value

   $('#Combobox_id').find("option").eq(0).remove()    

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742297575a4417431.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信