0

I have few search forms and each form has an input value with class "search_input".

I want: on button click to add this:

<input type="submit" class="searchbtn" value="Search" />

next to each input <input type="text" class="search_input" autocomplete="off">.

Currently I am doing so using display none and on click im setting the display to block but the forms are too many so in order to save some kb's instead of typing that on every form, I'm asking if it possible with jQuery to add the input next to each .search_input

Thanks alot

1

4 Answers 4

3

Using jquery it's quiet easy to add control:

$('.search_input').after($('<input type="submit" class="searchbtn" value="Search" />'));
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks alot again. Give it another 4 minutes to accept your answer
2
var $input = $('<input type="submit" class="searchbtn" value="Search" />');
$(".search_input").after($input);

//OR
//$input.insertAfter(".search_input");

Comments

0
$("#button_id").click(function(){
  $('<input type="submit" class="searchbtn" value="Search" />').insertAfter(".search_input");
});

see docs: http://api.jquery.com/insertAfter/

Comments

0
$('#addSubmitButtons').click(function(e){
    $('.search_input').after('<input type="submit" class="searchbtn" value="Search" />');
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.