I’m trying to understand, how I could grab anchors title atribute, and insert it into input.
I tried this:
$(".choosebox a").click(function () {
var url = $(this).attr('title');
//alert(url);
$("input").text(url);
return false;
});
Alerting works great, but the title is not inserting inside the input.
What might be the correct way to do that?
P.S. If I want point to input one input, not all, then which syntax is appropriate? $("input[name='this-one']") ?
The problem is, probably, using
text()rather thanval(), aninputelement doesn’t really have atext()content, rather it has avalue, which jQuery addresses asval(), therefore this should work:References:
text().val().