这是脚本/头部中的代码:
<script type="text/javascript">
$(function () {
$('.HideButton').click(function () {
var theButton = $(this);
$('#disclaimer').slideToggle('slow', function () {
theButton.val($(this).is(':visible') ? 'Hide' : 'Show');
});
return false;
});
$('<h2></h2>').html($('#MessageText').val);
});
正文中的代码:
<p id="disclaimer" >
<input id="MessageText" type="text" /> //I this value to appear in an inserted h2 tag after the button toggles the <p>
</p>
<asp:Button ID="Button21" CssClass="HideButton" runat="server" Text="Hide" />
答案 0 :(得分:2)
$('<h2></h2>').html($('#MessageText').val);
值是一种方法,它应该是......
$('<h2></h2>').html($('#MessageText').val());
答案 1 :(得分:1)
如果我正确地阅读你的问题 - 我想你想要以下......
变化:
$(function () {
$('.HideButton').click(function () {
var theButton = $(this);
$('#disclaimer').slideToggle('slow', function () {
theButton.val($(this).is(':visible') ? 'Hide' : 'Show');
});
return false;
});
$('<h2></h2>').html($('#MessageText').val);
});
要:
$(function () {
$('.HideButton').click(function () {
var theButton = $(this);
$('#disclaimer').slideToggle('slow', function () {
theButton.val($(this).is(':visible') ? 'Hide' : 'Show');
});
theButton.after($('<h2></h2>').html($('#MessageText').val()));
return false;
});
});