I searched a lot trying do solve this problem but I just found specific solutions, I wonder if there's a way to select the previous input text independent of the HTML structure.
Don't know if that is possible but would be nice to have a "generic" solution for this problem.
Is that is not possible, this is my case:
<ul>
<div class="inputMusics">
<div class="music">
<li>
<label>Artist:</label>
<input class="artists" type="text" name="artistMusic[]" value="artist"/>
</li>
<li>
<label>Title:</label>
<input class="title" type="text" name="titleMusic[]" value="title"/>
</li>
<li>
<label>Album:</label>
<input class="albuns" type="text" name="albumMusic[]" value="album"/>
</li>
</div>
</div>
<button id="addMusic" type="button"> + Add musics</button>
<button id="removeMusic" type="button"> - Remove music</button>
$(".title").focus(function(){
// select the previous input
}
Thanks!