How do i get the new html content and its ID to work?

Issue with detecting and using id within replaceWith or new html code

Hi, I’m having an issue with replacewith. When i click on the div below
and replace the html. I am not able to use the id within the new div.
I even tried html instead of replaceWith and i am still not able to.

<div id="action"></div>

<javascript>
$("#action").click(function(){
var foo = $(this).attr('id');
//$("#"+foo).html("<div id="next">do this</div>");
$("#"+foo).replaceWith("<div id="next">do this</div>");
});
$("#next").click(function(){
var bar = $(this).attr('id');
alert(bar);
});
</script>

211 thoughts on “How do i get the new html content and its ID to work?”

  1. Does your website have a contact page? I’m having problems locating it but, I’d like to
    shoot you an email. I’ve got some recommendations for your
    blog you might be interested in hearing. Either way,
    great blog and I look forward to seeing it improve over time.

    Reply
  2. Интернет-платформа Joy casino начала деятельность на российском рынке более 7 лет
    назад. Пользователям сайта предложен сертифицированный программный продукт от популярных разработчиков.
    В ассортимент виртуальных развлечений вошли аппараты барабанного типа, карточные и настольные игры в режиме live и прогнозы на спорт
    и киберспортивные дисциплины.

    Reply
  3. 150327 276885Youll locate some fascinating points in time in this post but I do not know if I see all of them center to heart. Theres some validity but I will take hold opinion until I appear into it further. Fantastic post , thanks and we want significantly a lot more! Added to FeedBurner too 25595

    Reply
  4. 633046 426454Cause thats required valuable affiliate business rules to get you started on participating in circumstances appropriate for your incredible web-based business concern. Inernet marketing 821368

    Reply