I have a code already written in javascript:
var objTo = document.getElementById('krishna')
var href1 = document.createElement("div");
href1.setAttribute("style","float: left");
objTo.appendChild(href1);
Already so many elements are appended to href1 in javascript.
I want to add some more elements to href1 using jquery
I tried href1.append("<br>");
it says href1.append is not a function
How to use jquery append to append an element to href1.
You need to turn the native element into a jQuery object. Native elements don't recognize jQuery methods
Try
$(href1).append("<br>");
If you want to do all this with jQuery alone the code is quite simple
// create new <div> element and apply style
var href1 = $("<div>").css('float','left');
// append to id=krishna
$('#krishna').append(href1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.