0
I’m messing with a Select, where I select your index. The problem that after setting the index I have to put it inside a div.
Only it does not receive the index set, it goes with the default. What function of jquery, cut select with what was assigned to it, so I can insert what I want.
<select class="my">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select class="menor">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
$(document).ready(function() {
$(".my, .menor").prop('selectedIndex', -1);
$(".my").after("<div class='maior'></div>").prependTo(".maior");
});
Thank you for helping. I could understand what you meant, but in my situation, it’s when you load ready() the page. Because I have to set it to copy in. I tried -1 and unsuccessfully: https://jsfiddle.net/7w6zqrbL/4/
– abcd
@abcd so you want me to be left with no set option? like this? -> https://jsfiddle.net/7w6zqrbL/5/
– Sergio
It is a plugin, hence when the person loads, it can set as -1, or any other value, if it seven a number too high than the existing options it returns -1. Then I create below select a few Ivs (simulating a select), then play the select inside the parent div. After playing I try to pick up the options. I managed to accomplish what I wanted, by cloning and then taking the index of the main and playing for the cloned. ATT
– abcd
@I’m sorry, but I still don’t understand what you want to do. I think you have a pretty clear idea, but you haven’t put enough information in here for anyone who doesn’t know your app to figure out what you want. I would like to improve my answer, but I need to understand it better. Otherwise the question and answer are not useful to anyone else :P
– Sergio
I added the answer to the topic, the way I managed to solve it. As I said, I cloned the main select and put it inside the DIV I created, then I took the selected index from the main select and I step it to the cloned select and then I remove the main select. I got your idea to go from a select
– abcd
@abcd because you have 2 selects in HTML? it’s just for example or is that so in your app? which one is the main?
– Sergio