Reputation: 892
$(document).ready( function () {
$('#test').click(function(){
videofix();
});
}
function videofix(){
$('#article').text($('#article').val().replace(/\[video\](http:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9]+))\[\/video]/g,'[video=youtube;$3]$1[/video]'));
}
</script>
<textarea id="article" name="article"></textarea><br>
<input type="button" id="test" value="test">
Basically my problem is, the videofix function when called, while working it does not replace the text of the textarea. I've actually copied my code out of this to jsfiddle and tried it there and it worked. So I'm not sure what the hell is going on.
Upvotes: 2
Views: 18793
Reputation: 144689
For setting a value to textarea you should use val()
method instead of html()
;
$("#article").val("something");
Upvotes: 7
Reputation: 3900
The only textarea I see in your code has id="article"
. And you never set it's value using .html()
as far as I can see.
Anyway, if .html() doesn't work, maybe try this instead:
$("#article").empty().append(data);
Upvotes: 2