总新手,第一个项目和我做得不太好.需要简单搜索显示查询标题的YouTube视频:
这是我的JS:
$(function() {
$('#search-term').submit(function(event) {
event.preventDefault();
var searchTerm = $('#query').val();
getRequest(searchTerm);
});
});
function getRequest(searchTerm) {
var params = {
part: 'snippet',
key: '',
q: query
};
url = 'https://www.googleapis.com/youtube/v3/search';
$.getJSON(url, params, function(data) {
showResults(data.Search);
});
}
function showResults(results) {
var html = "";
$.each(results, function(index, value) {
html += '<p>' + video.snippet.title + '</p>';
console.log(video.snippet.title);
});
$('#search-results').html(html);
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<title>Youtube Project</title>
</head>
<body>
<form id="search-term">
Entry:
<br>
<input id="query" type="text">
<br>
<input type="submit" …Run Code Online (Sandbox Code Playgroud)我正在使用不允许我直接编辑每个页面上的html的软件.相反,我可以向页眉和页脚添加代码,以便在页面正文中编辑文本和代码.
我希望这个弹出窗口居中在页面上,而不是出现在顶部和侧面:
<a onclick="javascript:window.open('https://www.thelink.org/faf/login/loginParticipantPopUp.asp?ievent=1138380','loginwin','menubar=no,scrollbars=yes,resizable=yes,width=400,height=200')" href="#">click here</a>
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/jelane20/gt1ykmxs/
任何建议都将非常感谢能够编辑弹出窗口的属性.
我将字体设置为 15px,但在移动设备(特别是邮件 > gmail)上查看电子邮件时,文本显得小得多。如何在不增加桌面大小的情况下增加移动设备的大小,我听说 gmail 会删除媒体查询。
<table>
<tr>
<td style="font-size: 15px;"><p style="font-size: 15px;">Some text</p></td>
</tr>
</table>Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我正在使用的软件不允许我直接编辑某些页面。如果查看者正在查看的页面包含特定字符串,我想将他们重定向到不同的 URL。
这是我尝试过的方法,但无论您位于网站的哪个页面,它似乎都会将您重定向到新位置。
<script>
var EDITURL = window.location.href;
if ('url:contains("testthis")') {
window.location.replace("http://www.test.com");
};
</script>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我想为每个输入和标签元素动态添加id和for属性.
<div id="splash">
<div class="tab">
<input id="tab-1">
<label for="tab-1"><label>
</div>
<div class="tab">
<input id="tab-2">
<label for="tab-2"><label>
</div>
<div class="tab">
<input id="tab-3">
<label for="tab-3"><label>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
所以基本上我希望输入的id是tab-#,每个输入字段的#增加1,标签的"for ="属性相同.