Reputation: 4283
I'm just now getting my feet wet with jQuery (and CSS to an extent) and stumble a lot at simply targeting the right selector. Even if I directly copy and paste the CSS path from Firebug, half the time it won't work.
At the moment, I'm trying to alter the Wibiya toolbar to use my own Wordpress built-in URL shortener instead of theirs, and I figured the easiest way would be to just target it's selector and change it via jQuery.
Here's the code I'm using right now (doesn't work):
$("input#linkUrl").text("testing");
I've tried some other selectors including the full, huge copied Firebug path with no luck as well.
The URL I'm using this on (for anyone wanting to inspect it themselves) is Meanwhile In America, the toolbar is at the very bottom, the item in question is the URL shown where there is the "Copy" button.
UPDATE 10/4/2013 4:22 PM: anyone else have any suggestions? Still not working.
Upvotes: 0
Views: 82
Reputation: 3450
From jQuery documentation:
The .text() method cannot be used on form inputs or scripts.
To set or get the text value of input or textarea elements, use the .val() method.
$("input#linkUrl").val("testing");
Upvotes: 3
Reputation: 29434
You probably want $("input#linkUrl").val("testing");
since your target element is an input.
You can also shorten your selector to #linkUrl
if you want to.
Upvotes: 4