Reputation: 37464
Anyone see why this wouldnt work as intended!?
$('.project_ref_input').val().empty();
I've tried with .text() and just with .empty()...no luck!?
.project_ref_input is the class of the input
This is the complete jquery code:
$('.project_ref_input').live('change',function(){
var project_ref_input=$(this).val();
$(this).next().replaceWith("<p>" + project_ref_input + "</p>");
$('.project_ref_input').val().empty();
});
Upvotes: 2
Views: 2318
Reputation: 8117
Try by removing .val(), since .val() returns string, we don't have empty function available for string is javascript
Upvotes: 0
Reputation: 342635
Or:
$('.project_ref_input').removeAttr('value');
http://api.jquery.com/removeAttr/
Upvotes: 1
Reputation: 138017
It doesn't work because val
doesn't return a jQuery object, but a string. To set a value, pass it to val
as the argument. try:
$('.project_ref_input').val('');
Upvotes: 5