I know I am asking pretty long question but I really in a need of this solution.
I need to create a looping
search select boxes for search filter option. For example,
After that I need to add another select menu to enter another set of data, in this case the previously selected item should not be present in the looped select menu
Here is the basic code updated
Image 1
Image 2
Note: In my fiddle plese refre the first action when you click on the + button, I need the same effect when the looped row's button click and as soon as I click on the first + button it should turn to close button.
HTML:
<div class="filtr">
<!-- we'll clone this one... -->
<div class="loop">
<select>
<option>By Name</option>
<option>By ID</option>
<option>By Place</option>
<option>By Post</option>
<option>By Tag</option>
</select>
<input type="text" />
<button class="btn del">X</button>
<button class="btn add">+</button>
</div>
<!-- here ...-->
</div>
CSS (IE9+):
.filtr{
width:350px;
}
.loop {
background:#ccc;
display:inline-block;
}
.loop .add{
display:none;
}
.loop:only-of-type .del{
display:none;
}
.loop:only-of-type .add{
display:inline;
}
.loop:last-of-type:not(:only-of-type) .add{
display:inline;
}
jQuery:
$filtr = $('.filtr');
$filtr.on('click', '.add', function(){
$(this).closest('.loop').clone().appendTo( $filtr );
});
$filtr.on('click', '.del', function(){
$(this).closest('.loop').remove();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.