I've been learning more and more about jQuery but here I've become stuck.
I have a code to change the color of a div when a checkbox is cliked, that works fine.
After this I want to be able to change the contents of a textarea on focus, I tried this:
//textarea
$("textarea").focus(function(){
if ($(this).contains('Skriv valg av headset her')){
$(this).replaceWith('');
});
But there is no effect. Do I have some syntax errors or am I taking the wrong approach?
There's the
$.containsfunction and the:containsselector, but nojQuery.fn.contains. You're looking forvalhere I believe:replaceWithis also wrong here - if that were to work (and it shouldn't I believe because it takes either a DOM element or a HTML text) it would remove thetextareaelement (which is better done withremoveanyway)