我正在尝试获取放置在 html 页面上的特定锚标记的href 值。
html标签结构
<a rel="nofollow" title="some title" href="http://www.this-is-what-i-need.com/just-this.html"><span><em class="buttonGo"></em>Go to this page</span></a>
Run Code Online (Sandbox Code Playgroud)
如何使用buttonGo类名从上面的锚标记获取href值?
我正在开发一个网页,并在页面上使用一些javascripts来移动一些html元素,但我发现javascript代码在页面顶部<!doctype html>
或任何类型的<!doctype>s添加到页面顶部时无效!这个错误是什么?
我搜索谷歌,我发现<!doctype html>是正确的格式甚至stackoverflow源代码有它,但当我使用它javascripts不工作,但当它删除脚本工作正常和HTML对象正在移动但我的风格已消失因为删除<!doctype html>
<!doctype html> when this line removed it works(html element is moving)
<html>
<head>
<script type="text/javascript">
function scrollDiv(){
var obj = document.getElementById("movingDiv");
obj.style.left = 100;
obj.style.top = 10;
}
document.onclick = scrollDiv;
</script>
</head>
<body class="body">
<div class="maindiv" id="mainDiv">
<div class="html_js_code" style="text-align:center;">
<div id="movingDiv" style="position:absolute;left:100pt;top:10pt;border:1px blue
outset;width:160px;background-color:lightyellow;font-weight:bold;">Moving Div</div>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在使用AJAX通过PHP从MYSQL数据库中检索数据.
但是,如果找不到结果,则变量仍有两个空格.我发现问题使用了alert(data.length);.结果是2,这意味着有两个空格.
如何删除这些空格,以便在没有结果的情况下,我可以使用if(data == ''){}?
谢谢!
我在开发基于javascript的想法时遇到了问题..
这是主要代码,
$.post("datainlines.php", function(data) {
var lines = data.split("\n");
for (var i = 1; i < lines.length; i++) {
sitename= lines[i]; sitetype=lines[i++];
if(i/2 == '0'){ alert current values in sitename and sitetype variables}
}
} );
Run Code Online (Sandbox Code Playgroud)
这将通过POST获取datainlines.php中的数据,datainlines.php文件数据结构是这样的 -
Google
search
Stackoverflow
Questions
Yahoo
search
Facebook
social network
Run Code Online (Sandbox Code Playgroud)
如何获取网站名称和类型组,例如
Google
search
Run Code Online (Sandbox Code Playgroud)
然后
Stackoverflow
questions
Run Code Online (Sandbox Code Playgroud)
无论如何在for循环中每两个循环分组和警报?
我已经完成了一个网站的设计,现在我很想让它具有响应性,我只需要让它对PC做出响应,因为使用该网站的移动设备无法做到这一点.
我只是想知道iCloud家伙是如何做到这一点的,当你重新调整窗口大小时,所有元素定位和重新调整大小很好,他们是使用纯CSS还是混合使用CSS和JS?iCloud的
我找到了很多教程,但仍然无法弄清楚为什么它对我不起作用.
http://unstoppablerobotninja.com/demos/resize/
我的示例html结构:
<div id="place">
<div id="wrap">
<div id="1"><img src="">this div needs to be responsive</div>
<div id="2"><img src="">this too</div>
<div id="3"><img src="">and this</div>
<div id="4"><img src="">also this</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
当前的CSS样式:
#place{
position: relative;
width:3065px;
height:560px;
margin:0px;
}
#wrap,
{
width:975px;
height:480px;
position: absolute;
top:80px;
}
#1{
width:215px;
height:103px;
position: absolute;
left:0px;
top:0px;
background-color:#409da5;
}
#1 img,
{
width: 100%;
height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
我可以使用window.resize来检测窗口大小调整,然后使用jQuery更改元素的大小.
$(window).resize(function() {
var nh = $("#1")width() / ratio;
$("#1").css('height', nh …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过Laravel 4将文件上传到Amazon S3.
用户提交表单后,该文件将传递给我需要使用Amazon PHP SDK并将文件上传到Amazon S3存储桶的函数.
但是如何在不将文件保存到服务器的情况下直接将文件上传到Amazon S3.
我目前的代码是这样的,
private function uploadVideo($vid){
$file = $vid;
$filename = $file->getClientOriginalName();
if (!class_exists('S3'))require_once('S3.php');
if (!defined('awsAccessKey')) define('awsAccessKey', '123123123');
if (!defined('awsSecretKey')) define('awsSecretKey', '123123123');
$s3 = new S3(awsAccessKey, awsSecretKey);
$s3->putBucket("mybucket", S3::ACL_PUBLIC_READ);
$s3->putObject($vid, "mybucket",$filename , S3::ACL_PUBLIC_READ);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Laravel 的create方法存储数组
$input = Input::all();
$new_media = $this->media->create($input);
Run Code Online (Sandbox Code Playgroud)
或者
$input = Input::all();
$new_media = Media::create($input);
Run Code Online (Sandbox Code Playgroud)
两个代码都不起作用。
这是我得到的错误。
Method [create] does not exist.
Run Code Online (Sandbox Code Playgroud)
Laravel 文档在这里http://laravel.com/docs/4.2/eloquent
来自 Laravel 文档
// Create a new user in the database...
$user = User::create(array('name' => 'John'));
Run Code Online (Sandbox Code Playgroud)
媒体模型
<?php
class Media extends Eloquent {
protected $table = 'media';
protected $guarded = array();
public static $rules_video = array(
'title' => 'required',
'url' => 'required'
);
public static $rules_image = array(
'title' => 'required'
); …Run Code Online (Sandbox Code Playgroud) 我正试图the-box从它的底部设置元素的高度.
CSS
.the-box { position: absolute; left: 0px; right: 0px; width: 100%; height: 50%; z-index: 999; background-color: white; opacity: 0.5; }
.container { position: relative; }
Run Code Online (Sandbox Code Playgroud)
HTML
<div align="center" class="container">
<div class="the-box"> </div>
<iframe wmode="Opaque" class="video-iframe" width="100%" height="315" src="//www.youtube.com/embed/ZauRZNs8BMg" frameborder="0" allowfullscreen=""> </iframe>
</div>
Run Code Online (Sandbox Code Playgroud)
发生了什么事
_____________________
| | |
| | 50% |
| | |
| \/ |
| |
|____________________|
Run Code Online (Sandbox Code Playgroud)
我需要做的是
______________________
| |
| |
| /\ |
| | |
| | 50% |
|_________|___________| …Run Code Online (Sandbox Code Playgroud) 我有一个方法,每5秒迭代一个大数组.在每个循环中,我添加一些东西ArrayList.
我听说使用new需要更多内存.
我需要知道上面清空/清除的最佳方法是什么ArrayList.
private ArrayList<MyMarker> myArray;
public void callEveryFiveSeconds(){
myArray = new ArrayList<MyMarker>(); //clears previous array data
//grab array data from server
for (int i = 0; i < 200; i++) {
myArray.add(someData);
}
}
Run Code Online (Sandbox Code Playgroud)
要么
private ArrayList<MyMarker> myArray = new ArrayList<MyMarker>();
public void callEveryFiveSeconds(){
myArray = null; //clears previous array data
//grab array data from server
for (int i = 0; i < 200; i++) {
myArray.add(someData);
}
}
Run Code Online (Sandbox Code Playgroud)