What's the clearest commonly used idiom for this jQuery snippet?
$('#someTextarea').val( $('#someTextarea').val() + someString );
It feels clunky to wrap the original code in a one-line function
EDIT: So I can pass a function, which is cool... but my real intentions are for jsfiddles, where I currently do stuff like this:
function lazylog (str) {
$('#ta').val( $('#ta').val() + str + '\n' );
}
// or
function lazylogPlain (str) {
document.getElementById('ta').value += str + '\n';
}
// view results of little experiments
lazylog( test1() );
lazylog( test2() );
lazylog( test3() );
// etc...
Don't know if that context would produce different answers or just make me seem really lazy for wanting to type even less than that. console.log
doesn't count, I want the textarea.