我正在尝试添加ID,即html span中的$ hexcode值到数组中.我如何使用jQuery执行此操作?最终,我将需要获取这些十六进制值并将它们与颜色索引相匹配.
<?php
// display every color in the world
$r = 0;
$g = 0;
$b = 0;
$i = 0;
$step = 16;
for($b = 0; $b < 255; $b+=$step ) {
for($g = 0; $g < 255; $g+=$step) {
for($r = 0; $r < 255; $r+=$step) {
$hexcolor = str_pad(dechex($r), 2, "0", STR_PAD_LEFT).str_pad(dechex($g), 2, "0", STR_PAD_LEFT).str_pad(dechex($b), 2, "0", STR_PAD_LEFT);
echo '<span class="color_cell" id="'.$hexcolor.'" style="width: 5px; height: 5px; background-color:#'.$hexcolor.'; border: 1px dotted;"> </span>'
if($i%256 == 0) {
echo …Run Code Online (Sandbox Code Playgroud) 我的表单目前有两个提交按钮.一个用于Search另一个用于Mark Complete功能.只有在单击"标记完成"按钮提交表单并通过验证时,才需要显示确认对话框.有可能识别出来吗?我目前有以下confirmComplete功能:
function confirmComplete() {
alert("confirmComplete");
var answer=confirm("Are you sure you want to continue");
if (answer==true)
{
return true;
}
else
{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!
我目前正在从查询中检索对象列表List<NprDto>(NprDto类包含accountId,theDate1和theDate2),该查询返回NprDto具有重复accountIds的结果.我需要一个List<NproDto>唯一的唯一accountIds但保留对象.它只需要添加它遇到的第一个accountId并忽略其余的.
我正在尝试这个:
private List<NprDto> getUniqueAccountList(List<NprDto> nonUniqueAccountList) throws Exception {
Map<Long,NprDto> uniqueAccountsMapList = new HashMap<Long,NprDto>();
List<NprDto> uniqueAccountsList = null;
if(nonUniqueAccountList != null && !nonUniqueAccountList.isEmpty()) {
for(NprDto nprDto : nonUniqueAccountList) {
uniqueAccountsMapList.put(Long.valueOf(nprDto.getAccountId()), nprDto);
}
}
uniqueAccountsList = new ArrayList<NprDto>(uniqueAccountsMapList.values());
return uniqueAccountsList;
}
Run Code Online (Sandbox Code Playgroud)
但这似乎没有用,因为当我迭代返回的uniqueAccountsList后,它只会拾取第一个对象.
任何帮助将不胜感激.
我正在尝试将元素添加到关联数组中,colors = []
我想让它拥有["id":selected_color]但我的浏览器一直在崩溃(某个地方无限循环?)
我不确定我是否正确地将元素添加到数组中.
发生的事情是我点击了一个span元素,它的ID值设置为十六进制值,我正在尝试捕获该值并将其与 selected._color
<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script type="text/javascript">
var selected_color = "";
var colors = [];
$(document).ready(function() {
$(".color_cell").click(function(){
// ADD MY COLOR TO SELECTED COLOR'S ASSOCIATIVE ARRAY
colors[$(this).attr("id")] = selected_color;
console.log($(this).attr("id"));
$(this).css({'background-color':'white'});
$(this).unbind('click');
updateDisplay(colors);
alert("hi");
});
$(".btnColor").click(function(){
// MAKE SELECTED COLOR BE ME
alert("hey");
selected_color = $(this).attr("id");
}); // end button handler
}); // end ready()
function updateDisplay(colors) {
jQuery.each(colors, function(key, value) {
//it seems to crash here...
$("#storage_display").html("var "+$("#storage_display").html()+" " +value); …Run Code Online (Sandbox Code Playgroud) 我一直试图让这个窗口显示为弹出窗口.当我点击超链接时,它在字符4处给出了"无效参数".
window.open("notifMsg.htm","My Notification","status=no,height=545,width=433,resizable=no,toolbar=no,menubar=no,scrollbars=no");
Run Code Online (Sandbox Code Playgroud)
window.open("notifMsg.htm")工作,但一旦我添加更多的参数,它一直给出无效的参数.我看过w3学校,这看起来像是格式.
任何帮助将不胜感激!谢谢.