*)注意使用jquery设置css的语法
css("propertyname","value");#单个时时逗号
css({"propertyname":"value","propertyname":"value",...});#多个时时大括号,中间是冒号
*)jquery和js的方法是不同的
比如获取和设置textarea的内容 参考链接:https://blog.csdn.net/glgom/article/details/88142605
<script type="text/javascript">
function change(){
/** js设置 */
var test = document.getElementById("test");
test.innerHTML = "你好,地球!"; //方法1
test.value = "你好,中国!"; //方法2
test.innerText = "绿色地球!"; //方法3 /** jq设置 */
$("#test").html("你好、我好、大家好!"); //方法1
$("#test").val("幸福的日子"); //方法2
$("#test").text("html好学"); //方法3
}
</script>
我犯得错误 就是竟然以为这两个语言只是获取dom元素的方式有区别:
function virtual_click(){
// $('.jfk-button-img').click()
// $('#source').click()
console.log('事件已运行')
$('#source').css('background','#5d885d');//这个有用#我起初就是因为这样获取然后调用css方法就能设置样式才以为js和jq除了选择方法有区别而已。而完全没有想到过之前学的Atribute()方法和.style.color=''这种方法,而学这些的时候也没有认识到js和jq是不同的,哎
var tem=$('#source')#甚至还想到了这个,以为是直接$('').value=''会出现对象的属性错误这种可笑的想法
tem.value=' ';//这个没有用,不知道为啥,现在知道了,当然没用了阿
tem.val('');
}