I'm new to the area and I'm having a lot of trouble doing the following:
option
. So far so good: copies made successfully. for
in javascript to go through each option
copied and display a different phrase for each option
in the first line. I thought the following:
-
for
that runsoption
- Finding the phrase x in a
option
any - Found the phrase x in
option
: addselected
, so that the phrase appears as the first choice ofoption
.
Below is a test html code with the copy function, for better understanding:
<!-- ... <html>, <head>, jQuery, etc ... -->
<table cellpadding="10" cellspacing="10" border="1">
<tr>
<td>Lixo01</td>
<td class="Original" id="Linha1">
<select id="MaxAlarme3">
<option value="02">Teste1</option>
<option value="03">Teste2</option>
<option value="0">Teste3</option>
<option value="04">Teste4</option>
</select>
</td>
</tr>
<tr>
<td>Lixo02 teste</td>
<td class="Clonar" id="Linha2"></td>
</tr>
<tr>
<td>Lixo03 value 05</td>
<td class="Clonar" id="Linha3"></td>
</tr>
<tr>
<td>Lixo04</td>
<td class="Clonar" id="Linha4"></td>
</tr>
<tr>
<td>Lixo05</td>
<td class="Clonar" id="Linha5"></td>
</tr>
<tr>
<td>Lixo06</td>
<td class="Clonar" id="Linha6"></td>
</tr>
</table>
<script>
//variavel contar o tamanho das copias
$(document).ready(function() {
//Copia valor da Linha1.Classe
var Copiar = $("#Linha1.Original").html();
//Clona o valor da Linha 1 para a Classe Clonar
$(".Clonar").append(Copiar);
});
</script>