Hi i'm trying to append elements into one set from there class names but getting an error.
var temp=document.getElementsByClassName("test");
temp.push(document.getElementsByClassName("we"));
That's because getElementsByClassName returns a NodeList, an array-like object which doesn't have push method. You should convert the NodeList into an array and then use the push method.
var temp = [].slice.call(document.getElementsByClassName("test"));
temp.push(...);
Alternatively you can use the querySelectorAll method:
var list = document.querySelectorAll('.test, .we');
And if you are loading jQuery:
var $collection = $('.test, .we');
querySelectorAll method.You're using jQuery. You can do:
$('.test, .we')
There's also the jQuery .add() method which can be used like:
$('.test').add('.we')
By Using JQuery Yoou can easily get All Elements of Class and then Put These Elements into Another Class.
There is a Code for Solving this Problem :
$(document).ready(function(){
var a= $(".classname1").html();
$(".classname2").html(a);
});
This Code is help you to get All Elements of Classname1 and then You can Put them into Classname2.
jquery, but aren't doing the jquery way. In jquery, it would be$('.test', '.we')