我想动态创建一些HTML元素(3个html元素),然后将此html代码作为变量中的字符串返回.我不想将以下函数中的HTML代码写入某个div,但是,我想在var中返回它.
function createMyElements(id1,id2,id3){
//create anchor with id1
//create div with id 2
//create xyz with id3
//now return the html code of above created just now
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
http://codepen.io/Thisisntme/pen/rVRyJE是对我的网站的测试。我正在尝试添加一个流畅的轮播,由于某种原因,它不会在div中渲染第二个图像。这是没有所有其他html和css内容的轮播。http://codepen.io/Thisisntme/pen/waOeWa
<div class="gallery js-flickity">
<div class="gallery-cell">
<img src="https://4c95d0ec6dcefe3d6c4d74191bd78c322c485be4.googledrive.com/host/0Bxf7lERLL3TlfjlMT28zSU9RdUFqZ2ZzWlFyWFpKMzJIbUpBelFIUnlsbTVHVUlfNVJfaXc/ART.JPG" alt="art">
</div>
<div class="gallery-cell">
<img src="https://4c95d0ec6dcefe3d6c4d74191bd78c322c485be4.googledrive.com/host/0Bxf7lERLL3TlfjlMT28zSU9RdUFqZ2ZzWlFyWFpKMzJIbUpBelFIUnlsbTVHVUlfNVJfaXc/STUFF.jpg" alt="stuff">
</div>
<div class="gallery-cell">
</div>
<div class="gallery-cell"></div>
<div class="gallery-cell"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.gallery {
padding: 50px 0px 0px 0px;
}
.gallery img {
display: block;
width: 100%;
height:auto;
}
Run Code Online (Sandbox Code Playgroud)
继承人证明图像链接很好
哦,没有jQuery。
编辑:对于那些仍在乎的人,图像不再起作用。Google云端硬盘已停止让您从他们的服务器托管。
我在这里构建一个newtab页面:
http://codepen.io/Thisisntme/full/VvgeyV
此页面包含漂亮的设计内容和谷歌搜索栏.但是,当我按Enter键时,不是搜索谷歌,而是打开相同的窗口http://codepen.io/Thisisntme/full/VvgeyV?inputbox=TEST_INPUT ("TEST_INPUT"是输入框中的任何内容).
当我向左按下提交按钮时,它实际上是搜索.
按下回车键后如何进行此搜索?
这是对表单重要的代码.
HTML:
<form NAME="myform">
<div id = "textbox">
<INPUT type="text" name="inputbox" value="" placeholder="Search with me!">
</div>
<input type="button" name="button" value="Click" onClick="google(this.form)">
</form>
Run Code Online (Sandbox Code Playgroud)
CSS:
#backgroundstuff canvas {
outline: 0px;
position: fixed;
left: 0px;
top: 0px;
/*width: auto;
height: 100%;*/
z-index: -99;
}
Run Code Online (Sandbox Code Playgroud)
使用Javascript
function google(form) {
var gSearch = form.inputbox.value;
window.location.href = 'https://www.google.com/search?q=' + gSearch;
//window.location.replace('https://www.google.com/search?q=' + gSearch);
}
Run Code Online (Sandbox Code Playgroud) 编译器是否编译了一个简单的三元语句,以便编译一个简单的if else语句?另外,为什么编译器会被设计为以不同方式编译它们?
例如,这样:
int a = 169;
int b = 420;
int c;
c = a > b ? 42:69;
Run Code Online (Sandbox Code Playgroud)
编译成同样的东西:
int a = 169;
int b = 420;
int c;
if(a>b) c = 42;
else c = 69;
Run Code Online (Sandbox Code Playgroud)
这个问题不是关于哪个更好或何时使用每个问题,所以请不要在答案中包含这个问题.