我需要在jquery或javascript中创建全局二维数组
我的功能是这样的
<script>
var globalArray[0] = new Array();
function createArray(){
alert(globalArray[0]);
}
</script>
<div><input type='button' value='save' onclick='createArray();'> </div>
Run Code Online (Sandbox Code Playgroud)
点击该按钮我收到此错误 "globalArray[0] is undefined"
如何创建全局动态多维数组.
当'product-input'的值发生变化时,我希望'product-total'更新.我有活动,但我似乎无法提及'product-total'.
这是HTML:
<div class='product'>
<h2>Photo Prints up to 5” x 7”</h2>
<div class='product-total'></div>
<div class='choices'>
<input type='text' class='raw standard product-input' />
</div> <!-- END Choices -->
Standard: <input type='radio' class='quality standard' value='standard' />
Full: <input type='radio' class='quality full' value='full' />
</div> <!-- END Product -->
Run Code Online (Sandbox Code Playgroud)
和jQuery:
jQuery('input.product-input').change(function() {
jQuery('div.product-total', jQuery(this).parent('div.product')).html(total);
});
Run Code Online (Sandbox Code Playgroud) console.debug("slide number");
console.debug(slideNumber)
console.debug("divs");
console.debug(imageIDDivs);
var singleimageidDiv = imageIdDivs[slideNumber];
Run Code Online (Sandbox Code Playgroud)
这是我的javascript的一部分.在萤火虫中这是输出.
slide number
Inspec...0001647 (line 49)
1
Inspec...0001647 (line 50)
divs
Inspec...0001647 (line 52)
[div#75bf9997-f111-4cbe-bee7-0765ba3bb8ca.slideshowImage, div#68c33349-cae6-4c2d-a9ed-1f87b12f06a2.slideshowImage, div#9e068363-6613-4346-b1e3-2ff4a3e2223b.slideshowImage, div#963a1d6a-a744-4a81-8608-5475b8fb21b1.slideshowImage, div#bd3f116d-9af9-4ca0-a45c-a366fd166ed0.slideshowImage, div#8ad2a764-14ab-466f-a614-a3676cca2127.slideshowImage, div#e99b579a-8e09-42e5-8951-b00613bc333a.slideshowImage, div#843ccfe7-5708-4794-b0dd-b10350277c64.slideshowImage, div#1e24f5f4-de3a-4b4f-b23d-b6ef9b513dad.slideshowImage, div#e862c867-5b93-4a3b-a235-b7bc0ac9cf37.slideshowImage, div#d99ca360-952d-46ff-9bda-bc87e13ef0a2.slideshowImage]
Inspec...0001647 (line 53)
imageIdDivs is not defined
Run Code Online (Sandbox Code Playgroud)
它说没有定义imageIdDivs.然而,在它正上方的行中,我输出它很好,它有大量的div.和之前输出的slideNumber只是数字1.这怎么可能?
谢谢.
您好我正在尝试使用下面的代码.我喜欢代码,但我希望默认为DIV Area 1.我在下拉菜单中显示了DIV Area 1的HTML代码,但我希望Javascript默认显示DIV AREA 1.代码是什么?
<script type="text/javascript">
$(document).ready(function(){
$('.box').hide();
$('#dropdown').change(function() {
$('.box').hide();
$('#div' + $('#dropdown').val()).show();
});
});
</script>
<form>
<select id="dropdown" name="dropdown">
<option value="0">Choose</option>
<option value="area1" selected="selected">DIV Area 1</option>
<option value="area2">DIV Area 2</option>
<option value="area3">DIV Area 3</option>
</select>
</form>
<div id="divarea1" class="box">DIV Area 1</div>
<div id="divarea2" class="box">DIV Area 2</div>
<div id="divarea3" class="box">DIV Area 3</div>
Run Code Online (Sandbox Code Playgroud) 我有一个包含不同值的数组,我想将它们拆分并在浏览器中打印.但我想提醒它第一个价值.我已经做了一个功能,但它没有做到
<script type="text/javascript">
$(function(){
var jam= new Array("first","second","third","fourth");
var Klnew= jam.split(",");
//for(i=0;i<Klnew.length;i++) {}
alert(Klnew[0])
});
</script>
Run Code Online (Sandbox Code Playgroud) index = 5;
alert($('ul li:eq(index) a',context).html());
Run Code Online (Sandbox Code Playgroud)
此脚本将提醒:"Null",但是当我更改为:
alert($('ul li:eq(5) a',context).html()); // it works
Run Code Online (Sandbox Code Playgroud)
那么这个脚本有什么问题?
我正在解析json以获取数据,但它显示未定义的错误.我正在使用以下代码.
JSON数据: -
[{"id":"1","name":"vikash","email":"vikash@yahoo.com","phone":"98744254114"},false]
Run Code Online (Sandbox Code Playgroud)
JavaScript的: -
function getid(id) {
//document.getElementById('pid').value=id;
$.ajax({
url: "page.php?id=" + id,
success: function(result) {
alert(result);
var a = console.log(result.name);
alert(a);
}
});
}?
Run Code Online (Sandbox Code Playgroud) 是否有可能在我的JS中添加其他功能:
如果响应==成功重定向到home
如果响应==失败重定向失败
$.ajax({
type: "POST",
url: action,
data: form_data,
success: function(response) {
if (response == 'success')
window.location.replace("home");
else
$("#message").html("<div class='error_log'><p class='error'>Invalid username and/or password.</p></div>");
}
});?
Run Code Online (Sandbox Code Playgroud) 我的IF语句中有多个条件,但只有第二个条件工作,换句话说,未检测到空值.我知道字段为空或空,但它没有检测到它.只有在保留第二个条件并删除第一个条件时才会触发电子邮件,但我想在发送电子邮件之前检查这两个条件.谢谢,这是我的代码
string k = gr.Cells[9].Text;
DateTime strExpectedSubDate = DateTime.Parse(gr.Cells[3].Text);
DateTime strDate = DateTime.Now.Date;
if (k == null && strExpectedSubDate < strDate)
{
send email();
Run Code Online (Sandbox Code Playgroud) 我做错了什么?当我运行此代码时,不显示任何内容.
JavaScript代码:
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
$(".whocares:not(:contains('' + month + '/' + day + '/'+ year + ''))").remove();?
Run Code Online (Sandbox Code Playgroud)
和HTML:
<div class="whocares">hi</div> <div class="whocares">12/26/2012 i like cake two</div> <div class="whocares">hi</div>
Run Code Online (Sandbox Code Playgroud)