#Jquery:是否可以在不使用id,class,name的情况下传递输入值? [关闭]

In one of the company while giving interview as a PHP Developer.

He asked me, How to pass variable in jQuery without using name attribute , id and class??

Yes, you can mention the element itself.

For example:

<p>This is a paragraph</p>

$("p").text("Test message");  // This will select all p tags.

Yes ,there are many selectors in jquery read here

EXAMPLE

$('input[type="text"]').val();

Your interviewer wanted to know about attribute selectors from you:

Example:

$( "input[value='Foo Bar']" ) //select the input which value is 'Foo Bar'