what does the following Line of code do in javascript $('div[class^="remainingQtyErrMsg"]').hide();

what does the following Line of code do in javascript/JQuery?

$('div[class^="remainingQtyErrMsg"]').hide();

Answers 1

  • Attribute Starts With Selector [name^=?value?]

    Selects elements that have the specified attribute with a value beginning exactly with a given string.

    $('div[class^="remainingQtyErrMsg"]').hide();
    

    will select all the <div> elements whose class starts with remainingQtyErrMsg string.

    This will only select elements whose class contains first class starting with remainingQtyErrMsg If the class attribute contains many classes and the class starting with remainingQtyErrMsg is not first class, then this selector will not work.


Related Articles