正如您从我的代码中可以看出的那样。我对此很新,所以请尽量保持您的答案简单。使用toUpperCase方法使p元素以大写形式显示
这个任务是让我输入的任何名字都以大写字母返回。
但我希望一切都以大写显示,名称和段落。我尝试过所有我能想到的事情,我觉得这很简单。
这是我到目前为止有:
$(document).ready(function() {
$("#letter form").submit(function(event) {
var nameInput = $("input#name").val().toUpperCase();
$(".name1").text(nameInput);
$("#response").show();
event.preventDefault();
});
});
#response {
display: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<!--link href="css/styles.css" rel="stylesheet" type="text/css"-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!--script src="js/scripts.js"></script-->
<div class="container">
<h1>Fill in the blanks to write your story!</h1>
<div id="letter">
<form>
<div class="form-group">
<label for="name">A name</label>
<input id="name" class="form-control" type="text">
</div>
<button type="submit" class="btn">Show me the response</button>
</form>
</div>
<div id="response">
<h1>A fantastical adventure</h1>
<blockquote>
<p><span class="name1"></span>, Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</blockquote>
</div>
</div>
当然,剪切和粘贴在这里唯一的错误......但你的jQuery和BootStap外部'script'电话是相反的。在Bootstrap之前放置jQuery。 –
[在javascript中将小写字母转换为大写]可能的副本(https://stackoverflow.com/questions/2354716/convert-lowercase-letter-to-upper-case-in-javascript) – TalkLittle
是的,这是一个复制和粘贴错误。尽管谢谢! – rainbowpudding