Jquery Hide by Name as a Selector

11,825

Solution 1

$("input[name='when_is_escrow_set_to_close']").hide();
 //^^^selectortype^^^^^attribute name="attributevalue"

reference attribute-equals-selector

Solution 2

You need Attribute Equals Selector [name="value"]

Live Demo

$('[name=when_is_escrow_set_to_close]').hide();

Description: Selects elements that have the specified attribute with a value exactly equal to a certain value.

Share:
11,825
Dek Dek
Author by

Dek Dek

Updated on June 04, 2022

Comments

  • Dek Dek
    Dek Dek almost 2 years

    I would like to ask if how to hide a specific field using its name. For example:

    <input type="text" name="when_is_escrow_set_to_close" class=" regular-text" value="" />

    I want to hide this field. In normal jquery with id and class we hide it by:

    $('.classname').hide();

    But how to use the same query when we need to call the selector by name.

    Thanks