小编Jug*_*Bob的帖子

在警报中使用 getElementById

这是我的代码:

<form method="GET">
<input type="text" class="form" name="name" placeholder="Enter your name!" id="name">
<input type="submit" onclick="return clicked();" value="I'm ready!">
</form>
<script>
function clicked() {
 return confirm('Hiya,');
}
var email = document.getElementById('name').value;
</script>
Run Code Online (Sandbox Code Playgroud)

我进行了搜索,但找不到任何与我的问题相匹配的主题。在当前仅显示“Hiya”的返回确认中,我希望它还包含用户在文本输入中输入的名称。

如有帮助,将不胜感激。

javascript

5
推荐指数
1
解决办法
2万
查看次数

在div标签内添加<br>标签失败

我有这个HTML代码:

<div id="welcomename">
    <h1>Welcome! What's your name?</h1>
    <input type="text" class="form" name="name" placeholder="Your name here!" id="name"/>
    <input type="button" onclick="clicked();" value="I'm ready!"/>
</div>
<br>
Run Code Online (Sandbox Code Playgroud)

这非常完美,但我有理由,我需要<br>div 'welcomename' 内部.当我这样做时,它不起作用.

其他代码:

<div id="hiddenDiv" style="display: none;">
    <h1 id="welcomehowareyou">How are you today, ?</h1>
    <form id="welcomehowareyou2" method="post">
        <select name="mood" onchange="popup(this.options.selectedIndex)">
            <option value="" disabled selected>How are you?</option>
            <option>I'm doing great, thanks!</option>
            <option>I'm fine, but could be better</option>
            <option>I feel absolutely terrible today.</option>
            <!--<input type="submit" value="Done!"/>-->
    </form>
    <p></p>
</div>
Run Code Online (Sandbox Code Playgroud)

html

5
推荐指数
1
解决办法
2万
查看次数

如果为空,则摇动文本输入

我有这个 Javascript 和 HTML 代码:

<script>
window.onload = function() {
    function validate(e) {
        var username = document.getElementById('username');
        if (username.value.trim() == '') {
            username.style.backgroundColor = '#ff4c4c';
            e.preventDefault();
        } else {
            username.style.backgroundColor = null;
        }
        var password = document.getElementById('password');
        if (password.value.trim() == '') {
            password.style.backgroundColor = '#ff4c4c';
            e.preventDefault();
        }else {
            password.style.backgroundColor = null;
        }
    }
    document.getElementById('login').addEventListener('submit', validate);
}
</script>

<div id="navrow">
    <img style="float: left;" src="questerslogoresized.png" />
    <ul>
        <li>Register</li>&nbsp&nbsp&nbsp</li>
        <li>About</li>&nbsp&nbsp&nbsp</li>
        <li>Reviews</li>&nbsp&nbsp&nbsp</li>
        <form id='login'  action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post'>
            <div style="position: absolute; right: 120px;"> …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

2
推荐指数
1
解决办法
8823
查看次数

标签 统计

html ×2

javascript ×2

jquery ×1