我写了这段代码,但是当我运行它时,我只得到一个空白页面.怎么了?看来我接近答案了.我已经尝试了一切,但它仍然无法正常工作.
class Button extends React.Component {
constructor(props) {
super(props);
this.state = {
random: 0
}
}
render() {
var min = 1;
var max = 100;
var rand = min + (Math.random() * (max-min));
handleClick() {
this.setState ({this.state.random + this.rand})
}
return (
<div>
<button value="Click me!" onClick={this.handleClick.bind(this)></button>
</div>
);
React.render(<Button />, document.querySelector('#container'));
}
}
Run Code Online (Sandbox Code Playgroud)
JSFIDLLE:https://jsfiddle.net/1cban4oy/12/
我使用的库提供下面的下划线.我想覆盖它而不显示下划线.
我的尝试:
.remove {
text-decoration: none !important;
}
.un {
display: inline-block;
}
.un:after {
content: '';
width: 0px;
height: 1px;
display: block;
background: black;
transition: 300ms;
}
.un:hover:after {
width: 100%;
}Run Code Online (Sandbox Code Playgroud)
<span class="un remove">Underlined Text - Or to be underlined</span>Run Code Online (Sandbox Code Playgroud)
我有一个脚本删除记录而不刷新.我还是javascript的新手,并试图学习如何调出这个脚本.这就是我所拥有的.
我的按钮:
<button id="<?php echo $rrr['id']; ?>" class="delbutton" onclick="">Delete</button>
Run Code Online (Sandbox Code Playgroud)
我的Javascript:
<script type="text/javascript" >
$(function() {
$(".delbutton").click(function() {
var del_id = $(this).attr("id");
var info = 'id=' + del_id;
if (confirm("Sure you want to delete this note? This cannot be undone later.")) {
$.ajax({
type : "POST",
url : "delete-note.php", //URL to the delete php script
data : info,
success : function() {
}
});
$(this).parents(".record").animate("fast").animate({
opacity : "hide"
}, "slow");
}
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
我在没有重新加载的情况下进行删除研究时从其他人那里借用了这段代码.通常我会看到一个函数看起来像这样:
function myFunction()
Run Code Online (Sandbox Code Playgroud)
然后我可以使用onclick这样调用它:
onclick="myFunction()"
Run Code Online (Sandbox Code Playgroud)
按照这个脚本的编写方式,我不确定我应该调用什么"函数",或者我是否需要在某处添加名称. …