jquery html();没有按钮样式
在jquerymobile中,我尝试用一些按钮替换标题。我使用jquery中的html()函数来实现 问题是按钮中的图标丢失了,看起来不像原来的div 我怎样才能解决它? HTML:jquery html();没有按钮样式,jquery,jquery-mobile,Jquery,Jquery Mobile,在jquerymobile中,我尝试用一些按钮替换标题。我使用jquery中的html()函数来实现 问题是按钮中的图标丢失了,看起来不像原来的div 我怎样才能解决它? HTML: <div data-role="page" id="index"> <div id="header" data-theme="b" data-role="header"> <h1>replace this with some buttons<
<div data-role="page" id="index">
<div id="header" data-theme="b" data-role="header">
<h1>replace this with some buttons</h1>
</div>
<div data-role="content">
<div id="map"></div>
</div>
</div>
<!-- div to instert-->
<span id="downBut"><center>
<button type="submit" id="down" style="width: 110px" data-mini="true" data-theme="a" data-transition="pop" data-icon="carat-d">Download</button>
<button type="submit" id="down" style="width: 110px" data-mini="true" data-theme="a" data-transition="pop" data-icon="delete">cancel</button>
</center></span>
// make the from header buttons
$("#header").html($("#downBut"));
.ui-header {
height: 40px;
}
.ui-content {
position: absolute;
top: 40px;
right: 0;
bottom: 0;
left: 0;
padding: 0 !important;
margin: 0;
}
h1 {
margin: 0 auto;
}
Css:
<div data-role="page" id="index">
<div id="header" data-theme="b" data-role="header">
<h1>replace this with some buttons</h1>
</div>
<div data-role="content">
<div id="map"></div>
</div>
</div>
<!-- div to instert-->
<span id="downBut"><center>
<button type="submit" id="down" style="width: 110px" data-mini="true" data-theme="a" data-transition="pop" data-icon="carat-d">Download</button>
<button type="submit" id="down" style="width: 110px" data-mini="true" data-theme="a" data-transition="pop" data-icon="delete">cancel</button>
</center></span>
// make the from header buttons
$("#header").html($("#downBut"));
.ui-header {
height: 40px;
}
.ui-content {
position: absolute;
top: 40px;
right: 0;
bottom: 0;
left: 0;
padding: 0 !important;
margin: 0;
}
h1 {
margin: 0 auto;
}
在用按钮替换html后,必须调用
create
forheader
div
$('#header').html($('#downBut'));
$('#header').trigger('create');
您有两个按钮具有相同的id
向下
和不同的样式。将每个按钮的id更改为不同的id,或者改为给它们类。这是因为这些按钮最初位于data role=“page”
div之外,因此jQuery mobile在首次创建页面时不会对它们进行“增强”。这正是我想要的。非常感谢。