这是我使用JavaScript的第一天,我需要一个简单演示的帮助.我需要从中获取值class="populateValue",并使其填充文本框并在单击按钮时发出警报.
现在它正在'[object Object]'文本框和警报中返回.
我的代码是:
<section>
<form>
<input type="text" id="demoText" />
<button class="populateValue" value="1234">Populate Value</button>
</form>
</section>
<script>
$(document).ready(function () {
$('.populateValue').on('click', function (event) {
event.preventDefault();
$('#demoText').val($('.populateValue'))
alert($('#demoText').val());
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我正在写一些jquery,它获得2个div的高度并将另一个div设置为组合高度.
var height1 = $("#heightSelector2").height();
var height2 =$("#heightSelector3").height();
var maxHeight = height1 + height2;
console.log(maxHeight);
Run Code Online (Sandbox Code Playgroud)
我现在如何设置$("#heighSelector1")= maxHeight?我知道我还需要在那里添加px,我已经看到了一些例子,但还不够清楚.
我正在制作一个危险的游戏.当我点击一个div时,我想对它做一些影响.但是,我甚至无法让一个简单的.hide工作.有任何想法吗?
<!DOCTYPE html>
<html lang="en">
<head>
<title>Jeopardy</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/customStyles.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/flip.js"></script>
</head>
<body>
<div class ="container">
<div class="row">
<div class="prizeAmount">
<div class="span2">
<h3 id="test">100</h3>
</div>
<div class="span2">
<h3>100</h3>
</div>
<div class="span2">
<h3>100</h3>
</div>
<div class="span2">
<h3>100</h3>
</div>
<div class="span2">
<h3>100</h3>
</div>
<div class="span2">
<h3>100</h3>
</div>
</div>
</div>
</div><!--close container-->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
JavaScript的
$(function() {
$('#span2').click(function() {
$(this).hide(400);
/*$('#span2').hide(400); <--tried this also */
});
});
Run Code Online (Sandbox Code Playgroud)
我曾经使用过jquery来为网站上的导航设置动画.我错过了一些明显的东西吗
我正在使用一个API,它接受来自名为#tags的输入字段的字符串数组.最好的方法是什么?它还应删除"标签"之间的任何逗号,如果没有标签,则为[].
输入:tag1,tag2,tag3变为:["tag1","tag2","tag3"]
HTML
<input id="tags" type="text" placeholder="tags" name="" value="">
Run Code Online (Sandbox Code Playgroud)
我如何获得标签值:
createPost('canvasID',{tags:$('#tags').val()});
Run Code Online (Sandbox Code Playgroud) 你如何在文本编辑器组件中做相对链接?默认情况下,当我使用相对链接到外部页面时,Adobe AEM不喜欢.它将它们剥离并显示断开的链接符号.
我想<a href>从特定div中删除所有内容.
<div class="postInfo">
<a href>
</div>
Run Code Online (Sandbox Code Playgroud)
我在尝试
$('.postInfo href').remove();
Run Code Online (Sandbox Code Playgroud)
那不行.我究竟做错了什么?