javascript - how to set This in element input without tagging ID's -
5 input type, without tagging id's; if click input prompt command appear , enter name?; after entering name how can codes jquery of "this.value = person"...
<div class="lines"> <input type="text"><span>7-5</span></input> <input type="text"><span>7-6</span></input> <input type="text"><span>7-7</span></input> <input type="text"><span>7-8</span></input> <input type="text"><span>7-9</span></input> </div>
then jquery are
$(document).ready(function(e){ var elementthis = $("input").click(function(){ var person = prompt("please enter name:"); if (person != null) { this['input'] = person; } $(this).css("background-color","green"); }); });
please help. didn't input person = prompt on clickable inputs.
well slight modification here
$(document).ready(function(e){ $("input").click(function(){ var that=$(this);//create reference var person = prompt("please enter name:"); if (person) { //as per @roko c.buljan's suggestion that.val(person); //assign val //or $(this) fine that.css("background-color","green");//as per @roko c.buljan's suggestion //you can move here in case cancel clicked } }); });
and yea no </input>
@roko c.buljan said. <input>
cannot have closing tag.
Comments
Post a Comment