html点击按钮状态改变,添加元素的状态改变按钮的Html

/* css for button to change size on click */

.button:focus {

width: 99%;

height: 500px;

}

//below is the script that handles the auto scroll to the button clicked on screen.

$(document).ready(function() {

$('.button').click(function() {

$('html,body').animate({ scrollTop: $(this).offset().top - (($(window).height()/1.5) - $(this).outerHeight(true))/2 }, 2000);

$(this).empty(); //empty title and author to prepare for recipe

$(this).append("Recipe Instructions Below");

});

});

在一个网站我建设我拉添加到数据库中的最新信息,并在一个按钮,可点击显示每一行。我的目标是按钮的大小约为100px×60px,点击“聚焦”将会增加到屏幕宽度。添加元素的状态改变按钮的Html

现在,当我点击按钮时,我想清空按钮并用数据库中的更多信息替换它,即点击配方的说明。当我随后忽略或点击按钮时,我希望它恢复到原来的状态,只显示食谱名称和作者。

我在看这个的方式是按钮是对象,但我认为这是非常错误的。如果可能的话,任何人都可以给我任何反馈,以便更智能和更有效的方式来解决这个问题,因为我唯一的问题是单击时向按钮添加更多元素。我真的很感激任何反馈。

2016-04-06

Nathan

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
HTML中,你可以使用JavaScript或者jQuery来实现点隐藏文本框的功能。这里我将给出一个简单的示例,演示如何使用HTML、CSS和基本的JavaScript来完成这个任务。 ```html <!DOCTYPE html> <html lang="en"> <head> <style> .hidden { display: none; } </style> </head> <body> <input type="text" id="myText" placeholder="输入内容"> <button onclick="hideInput()">隐藏文本框</button> <script> function hideInput() { var input = document.getElementById("myText"); input.classList.toggle("hidden"); } </script> </body> </html> ``` 在这个例子中: 1. `input`元素是你的文本框,`placeholder`属性提供了输入提示。 2. `button`元素是一个点,`onclick`事件被设置为调用`hideInput`函数。 3. JavaScript中的`hideInput`函数会获取具有`id`为`myText`的输入框,然后通过改变它的`class`(添加或移除`hidden`)来切换其显示状态,当`hidden`存在时,文本框会被隐藏。 如果你想要使用更现代的方式,比如使用jQuery,代码会稍微简洁些: ```html <!DOCTYPE html> <html lang="en"> <head> <style> .hidden { display: none; } </style> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <input type="text" id="myText" placeholder="输入内容"> <button id="hideBtn">隐藏文本框</button> <script> $(document).ready(function () { $('#hideBtn').click(function () { $('#myText').toggleClass('hidden'); }); }); </script> </body> </html> ``` 在这个jQuery版本中,我们引入了jQuery库,并且在`#hideBtn`按上绑定了一个点事件,点时会切换`#myText`的`hidden`样式。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值