css - How to assign the content of a jquery variable to another variable -


i attempting assign content of variable variable. how do this? far have tried this:

var classname = $($(this).attr("class"););  $('.content').html(classname) 

edit:

please assume end value "var classname = $($(this).attr("class"););" point1

point 1 contains:

edit 2: (contains full code)

    <div class="content"><h1>testing hello world</h1><div class="position"> <div class="point1"> test<br> awewa<br> test <h1> test </h1> </div></div></div>      <script type="text/javascript">     var point1 = '<div class="content"><h1>testing hello world</h1><div class="position"> <div class="point1"> test<br> awewa<br> test <h1> test </h1> </div></div></div>';     var classname = "broken";     $('.content [class] [class]').click(function () {$(this).fadeto(250, 0.25, function () {     classname = $(this).attr("class");     $('.content').html(classname)      $(this).fadeto(250, 1.00);      });}     );      </script>    var point1 = '<div class="content"><h1>testing hello world</h1><div class="position"> <div class="point1"> test<br> awewa<br> test <h1> test </h1> </div></div></div>'; 

"$('.content').html(classname)" < classname of needs contain string in point1)

ok assuming understood clearly. have html stored in variables same class names of element , on click of element. want ge html variable , assign content element classname .content.

$('.someclass').on('click',function(){     var classname = this.classname; // classname whic variable    var content = window[classname];    if(content)     $('.content').html(content); //assuming variable defined in window scope.  }); 

splitting this:-

window[classname] <-- variable defined in window scope.

update:-

try based on code update. since replacing content , click happen again should go delegated event handler using .on(), use .live older version of jquery.

   var classname = "broken";    $(document).on('click', '.content [class] [class]', function () {        $(this).fadeto(250, 0.25, function () {            classname = this.classname;            $('.content').html(window[classname]);            $(this).fadeto(250, 1.00);         });    }); 

demo


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -