是否有可能有一个onClick事件,第一次点击它使用一个功能,第二次点击它使用另一个?
例如
<p id="demo" onclick="goRed(), goBlue()">Click me to change my text color.</p>
<script>
function goRed() {
document.getElementById("demo").style.color = "red";
}
function goBlue() {
document.getElementById("demo").style.color = "blue";
}
</script>
Run Code Online (Sandbox Code Playgroud)
我可以这样做,所以onClick函数首先使用goRed(),然后在第二次点击后使用goBlue()吗?谢谢
我正在使用JQuery构建一个固定的头
目前一切正常,但不是将属性设置为类,而是想直接从css中调用它们.我对这种方法不太熟悉.
其中一个例子如下;
#header-main {
background-color: #ffffff;
min-height: 107px;
color: #8c8c8c;
}
#header-main .sabit{
position : fixed;
width: 100%;
z-index: 98;
padding-top: 35px;
border-bottom: 3px ridge #7BBD42;
}
Run Code Online (Sandbox Code Playgroud)
我是怎么做的; (工作)
var menu = $('#header-main');
if (...)
menu.css('position','fixed').css('width','100%').css('z-index','98').css('padding-top','35px').css('border-bottom','3px ridge #7BBD42');
else
menu.removeAttr('style'); //Back to normal
Run Code Online (Sandbox Code Playgroud)
我正在做什么来实现我想要的; (不工作)
var menu = $('#header-main');
if(...)
menu.addClass("sabit");
else
menu.removeClass("sabit"); //Back to normal
Run Code Online (Sandbox Code Playgroud)
我也试过menu.addClass(".sabit");,menu.addClass("#header-main .sabit");但没有一个工作.
我使用JQuery直接添加css类的错误是什么?
我想将 HTMLtable元素的背景颜色设置为:
“橄榄绿,Accent 3,更轻的 60%”
但我似乎无法找到它的颜色代码。我已经检查过这个网站http://amalfaro-wrk.tiddlyspace.com/Interface.ColorSchemes但他们只有以下代码:
“橄榄绿,Accent 3,打火机 80%,即#EBF1DE”。
有谁知道打火机百分比为 60% 的等效颜色代码?
我有一个函数从一个有序列表中删除列表元素,然后在当前一个列表之后找到所有有序列表,获取它们的第一个元素并将其附加到列出前一个元素.
问题:如果我从任何列表中删除第一个元素或者附加函数停止工作,我相信它是由于jQuery记住第一个元素是什么,因为它不再在它的位置它找不到它,但它应该只是重新定义/查找当前第一个孩子的特定列表中的新元素.这是功能:
function removeQueueItem(element) {
//Get ordered list of removed list element
var itemMonth = element.parents().eq(2); //li.queue-month
//Get all following lists
nextMonths = itemMonth.nextAll('.queue-month');
//Fade out removed element
element.parent().fadeOut(function(index){
//Remove element from DOM
element.remove();
nextMonths.each(function(index) {
//Check if next month has socks
if($(this).find('.item-dragable').length > 0) {
var firstItem = $(this).find('.item-dragable:first-child');
$(this).prev().find('ol').append(firstItem);
}
});
});
}
Run Code Online (Sandbox Code Playgroud)
JsFiddle - 在9月删除第一个项目,然后在8月删除任何项目,9月的第一个项目应该变成粉红色,但它没有发生.这就是问题所在.
我有一个使用CSS的网格display: table;.
我想做的是在行之间留一个间隙.
我有办法在使用时做到这一点display: table-row;.我已经尝试了padding,margin但这些对我不起作用,因为我想设置边距背景颜色.
我试图在jQuery Mobile框架中获得以下效果:
|-------------------------------------------------|
|[button1] HeaderText/Image [b1] [b2] [b3] |
|-------------------------------------------------|
Run Code Online (Sandbox Code Playgroud)
其中[b1],[b2]和[b3]标题中的小图像按钮.
这目前是否可能?
我试图通过javascript设置单选按钮的值.但我无法这样做.我试图做的是有4个单选按钮,其中一个已被选中.如果我选择其他单选按钮并单击"刷新",则应选择默认单选按钮.
http://jsfiddle.net/ds345/Un8XK/1/
HTML:
<fieldset data-role="controlgroup" data-type="vertical">
<input type="radio" name="radio" id="x" data-theme="a" />
<label for="x" style="color: White">X</label>
<input type="radio" name="radio" id="y" onclick="axisonoff(this)" data-theme="a" />
<label for="y" style="color: White">Y</label>
<input type="radio" name="radio" id="z" data-theme="a" />
<label for="z" >Z</label>
<input type="radio" name="radio" id="none" data-theme="a" />
<label for="none" style="color: White">None</label>
</fieldset>
<button id = "Refresh" value="Refresh">Refresh</button>
Run Code Online (Sandbox Code Playgroud)
JS:
$(document).ready(function () {
$("#none").attr("checked", true).checkboxradio("refresh"); // if this line is not present initially then it works for the 1st refresh.
});
$("#Refresh").click(function(){
$("#x").attr("checked", false).checkboxradio("refresh");
$("#y").attr("checked", false).checkboxradio("refresh");
$("#z").attr("checked", …Run Code Online (Sandbox Code Playgroud) 如果我尝试提取 11 月的第一天数字,效果很好:
var d = new Date(2013, 10, 1); // 1st of November 2013
d.toISOString(); // 2013-11-01T00:00:00.000Z (November)
d.getDay(); // 5 (Correct, 1st of November = Friday = 5)
Run Code Online (Sandbox Code Playgroud)
然而,由于英国的夏令时(时钟在 10 月底前进一小时),如果我尝试拉出 10 月的第一天,日期最终会设置为前一天的 23:00:
var d = new Date(2013, 9, 1); // 1st of October 2013
d.toISOString(); // 2013-09-30T23:00:00.000Z (September)
d.getDay(); // 2 (Last day number of September)
Run Code Online (Sandbox Code Playgroud)
我该如何处理这个问题,以便无论夏令时如何(以及用户身在何处的任何其他时钟调整),我总是在每月 1 日得到 00:00:00?
简短的问题:如何用css实现这种滚动效果? - >
我已经尝试过了:
#one {
background: url(http://images.buzzillions.com/images_products/07/02/iron-horse- maverick-elite-mountain-bike-performance-exclusive_13526_100.jpg);
background-repeat: no-repeat;
background-position: center center;
background-attachment:fixed;
}
#two {
background: url(http://img01.static-nextag.com/image/GMC-Denali-Road-Bike/1/000/006/107/006/610700673.jpg);
background-repeat: no-repeat;
background-position: center center;
background-attachment:fixed;
}
Run Code Online (Sandbox Code Playgroud)
谢谢!:)
我在下面有一个简单的片段,尝试使用CSS显示一个图标,content但不知道为什么它不显示,但是如果我直接放置类(现有的类fontawesome然后显示)而不是我的CSS.
不知道我在这里缺少什么,有人可以看看这里有什么不对吗?
.search-block {
max-width: 850px;
width: 100%;
margin: 0;
position: relative;
width: 100%;
background: #e5e5e5;
border-radius: 4px;
padding: 5px 10px;
box-sizing: border-box;
}
.search-block > .microphone-icon {
position: absolute;
right: 0;
font-family: FontAwesome;
content: "\f130";
font-size: 18px;
color: #fff;
width: 50px;
height: 50px;
background: #f00;
top:0;
}Run Code Online (Sandbox Code Playgroud)
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="search-block">
<h2 class="search-result"></h2>
<span class="microphone-icon"></span>
<span class="search-icon"></span>
</div>Run Code Online (Sandbox Code Playgroud)