Feeling like I'm the cusp of understanding Jqueries selectors and element handling - just not quite there yet!
The following html is being cloned so the user can add different issues, what I'm trying to do is add the class results to the last div so that I can display the results in the correct div. But when I hover over the element nothing changes, no javascript errors are being flagged so I presume its a case of my targeting the wrong element with my cack handed code.
Itd be really useful if someone could point me in the right direction for a decent tutorial on jquery selectors, have been reviewing the developer docs but without someone standing over my shoulder explaining stuff, some of the concepts and terminology can be hard to get your head round.
<div id="title-wrap1" style="margin-bottom:4px;" class="clonedInput">
<select name="Issues[]">
<option selected>Please Select...</option>
<?php
while($res = $title->fetch(PDO::FETCH_ASSOC)) {
echo "<option value=\"".$res['ID']."\">".$res['Issue']."</option>\n ";
}
?>
</select>
<div>
</div>
</div>
<div>
<input type="button" class="btnAdd" value="+" />
<input type="button" class="btnDel" value="-" />
</div>
This is my Javascript code
$(".clonedInput select").hover(
function () {
$('.clonedInput div', this).attr('class', 'results');
});
$(document).on('change','.clonedInput select',function() {
var data = {id: $(this).val()};
$.post('sub_db_handler.php', data, processResponse);
// var num = $('.clonedInput').length;
function processResponse(data) {
$('.clonedInput .results').html(data);
};
});