我有这个扰流板代码。
HTML:
<input type='button' class="splLink" value='Show'>
<div class="splCont">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br />
<input type='button' class="splLink" value='Show'>
<div class="splCont">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <br />
<input type='button' class="splLink" value='Show'>
<div class="splCont">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
</div>
JavaScript:
$(document).ready(function() {
$(".splLink").click(function() {
$(this).next().slideToggle("fast");
$(this).val($(this).val() == 'Show' ? 'Hide' : 'Show');
return false;
});
});
CSS:
.splCont {
display: none;
padding-top: 10pt;
}
.splLink {
font-family: arial, verdana, ms sans serif;
cursor: pointer;
}
示例:JSFIDDLE
谁能告诉我如何在代码中为按钮添加默认值,我可以在没有 value 属性的情况下在 html 中使用扰流板?像这样的东西:
<input type='button' class="splLink">
<div class="splCont">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>