How to find elements with 'value=x'?

后端 未结 6 1680
萌比男神i
萌比男神i 2020-12-08 09:14

I need to remove element that have value=\"123\". I know that all elements with different values are located into #attached_docs, but I don\'t know

相关标签:
6条回答
  • 2020-12-08 09:21

    Value exactly equal to 123:

    jQuery("#attached_docs[value='123']")
    

    Full reference: http://api.jquery.com/category/selectors/

    0 讨论(0)
  • 2020-12-08 09:23
    $('#attached_docs [value="123"]').find ... .remove();
    

    it should do your need however, you cannot duplicate id! remember it

    0 讨论(0)
  • 2020-12-08 09:24

    Use the following selector.

    $('#attached_docs [value=123]').remove();
    
    0 讨论(0)
  • 2020-12-08 09:25

    If the value is hardcoded in the source of the page using the value attribute then you can

    $('#attached_docs :input[value="123"]').remove();
    

    If you want to target elements that have a value of 123, which was set by the user or programmatically then use EDIT works both ways ..

    or

    $('#attached_docs :input').filter(function(){return this.value=='123'}).remove();
    

    demo http://jsfiddle.net/gaby/RcwXh/2/

    0 讨论(0)
  • 2020-12-08 09:25
    $(selector).filter(function(){return this.value==yourval}).remove();
    
    0 讨论(0)
  • 2020-12-08 09:39

    The following worked for me:

    $("[id=attached_docs][value=123]")
    
    0 讨论(0)
提交回复
热议问题