what is the best way to mix this
with other selectors in JQuery :filter
,[id=""]
and stuff like this, lets assume we wanna read .val()
of an input with name="input"
in form with that function is bind to it.
and if possible do they cost different ? if so why ?
here is the form
<form>
<input type="text" name="input">
</form>
like we have this
$("form").submit(function(){
if($(this).valid() == true){ //here i wanna read the value of inp开发者_如何学运维ut with name test}
The selector would just be:
var myVal = $("#test input[name=input]").val();
The this
version would use .find()
like this:
var myVal = $(this).find("input[name=input]").val();
...which is faster depends on the browser and what it supports, namely if it supports querying by selectors relatively.
use find maybe?
精彩评论