[Solved] jQuery methods on dynamic elements

You need to save $(this) after function() $(document).on(“click”,”.PlayPause”,function(){ var $this = $(this); //////Save this here////// if($(this).attr(‘src’) == ‘img/Play.png’){ $(this).attr(‘src’,’img/Pause.png’); var songId = $(this).parent().siblings(‘.Top_Container’).children(‘input’).val(); $.post(‘songs.php’,{songId : songId}, function(path){ //////////Use $this instead of $(this) inside here/////////// if(globalSong.playState && !($(this).hasClass(‘prevSelection’))){//$this $(‘.prevSelection’).attr(‘src’,’img/Play.png’); globalSong.pause(); $(‘.prevSelection’).removeClass(‘prevSelection’); } globalSong = soundManager.createSound({ id: (“sound” + songId), url: (songsPath + path), volume: userPrefVolume }); … Read more

[Solved] I’m trying to delete an image from a DB using AJAX, code works but cant tranverse DOM and hide image, why? [closed]

$(‘.deleteImage a’).click(function() { var thiz = $(this); // references the ‘.deleteImage a’ alert(‘Delete this?’); $.ajax({ type:’GET’, url: this, success: function(){ thiz.hide(‘slow’); //$(this) references to the ajax, use our thiz to reference to ‘.deleteImage a’ } }); return false; }); read the comments 2 solved I’m trying to delete an image from a DB using AJAX, … Read more