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 how to select element with value="123"
.
$('#attached_docs').find ... .remove();
Can you help me?
Use the querySelector method to get an element by data attribute, e.g. document. querySelector('[data-id="box1"]') . The querySelector method returns the first element that matches the provided selector or null if no element matches the selector in the document.
Syntax of jQuery Select Option$(“selector option: selected”); The jQuery select option is used to display selected content in the option tag. text syntax is below: var variableValue = $(“selector option: selected”).
You can use this jquery data() syntax for get data-id attribute value. $("selector"). data("textval"); You can use this jquery data() syntax for get data-textval attribute value.
jQuery :contains() SelectorThe :contains() selector selects elements containing the specified string. The string can be contained directly in the element as text, or in a child element. This is mostly used together with another selector to select the elements containing the text in a group (like in the example above).
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 EDIT works both ways ..123
, which was set by the user or programmatically then use
or
$('#attached_docs :input').filter(function(){return this.value=='123'}).remove();
demo http://jsfiddle.net/gaby/RcwXh/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With