Could do it like this:

$('#myElement:not(input)').text(s);
$('#myElement:input').val(s);

So you could have a function like:

function setElement(id, s) {
    $('#'+id+':not(input)').text(s);
    $('#'+id+':input').val(s);
};

So that whenever you set an element you can call:

setElement('someElementId', 'This is my string!');

On Feb 19, 10:18 am, AsymF <[EMAIL PROTECTED]> wrote:
> I want to update the contents of an element depending if it is a form
> element who's value can be set or if it is just an element who
> internal text can be set. How could I distinguish whether to use val()
> or text() on the fly?

Reply via email to