简体   繁体   中英

JQuery appendTo Div with ID instead of appendTo('body')

i have this code :

config.$leftnavbutton = $('<img src="' + config.defaultbuttons.leftnav[0] + '" id="btnlnav" >')
    .css({
        zIndex: 50, 
        position: 'absolute', 
        left: config.offsets.left + config.defaultbuttons.leftnav[1] + 'px', 
        top: config.offsets.top + config.defaultbuttons.leftnav[2] + 'px', 
        cursor: 'hand', 
        cursor: 'pointer'
    })
    .attr({ title: '' })
    .appendTo('body')

the code inserts an image at the end of body. i want it to insert it at the end of

<div id="slider-container">

is there any way? thanks!

You can try like this

.appendTo('#slider-container')

Please try this and let me know if works or not.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM