Im trying to change the value of an input field inside a div element “Cellbox”
i have tried
$('#CellBox').$(':input').val("Something");
$('#CellBox :input').val("Something");
$('#CellBox:input').val("Something");
$(':input #CellBox').val("Something");
nothing..
Edit:
thanks guys,
it was a mispelling – the most common error…
The
$('#CellBox :input').val("Something");
is correct
Number 2 would have worked as it looks for an element with the id
CellBoxwith a field of typeinputwithin it:Live example: http://jsfiddle.net/VzsjG/
What was wrong with the others?
Number 1:
Was a syntax error, just plain wrong – although it was close… if you would have used
.findin place of the second$it would have worked (Eg: http://jsfiddle.net/4s5RJ/)Number 3:
This incorrectly looks for an element with the id
CellBoxwhich is itself of type inputNumber 4:
This looks for an element of type input with an element inside it with the id
CellBox(ie, the wrong way round)