【发布时间】:2019-05-04 20:58:46
【问题描述】:
我使用 jquery 的时间不长。我正在尝试在另一个可放置元素中创建一个可放置元素。
通过嵌套它可以正常工作,但是由于新项目在创建之前没有类,我想在创建期间格式化 CSS 属性。
我正在使用.css{()} 函数,它适用于所有正常格式。
但是,我无法弄清楚将 H1 或 H2 设置为 none 或更改新可放置克隆中的标签的语法。
我尝试将h2 {display: 'none'} 添加为一行,但它不接受该格式。
//It is the bottom line of code, but this is to show how it is nested
//which is why I am trying to set the css this way.
drop: function (event, ui) {
$(this)
.append(ui.helper.clone(false)
.css({
position: 'relative',
left: '0px',
top: '0px',
height: "75px",
width: "100%"
})
.droppable({
accept: "#gallery > li",
classes: {
"ui-droppable-active": "ui-state-highlight"
},
drop: function (event, ui) {
$(this)
.append(ui.helper.clone(false)
.css({
position: 'relative',
display: 'inline-block',
padding: '1%',
left: '0px',
top: '0px',
height: "36px",
width: "auto",
h2 {display: 'none'} //right here is the problem.
【问题讨论】: