不确定这是否可能以及如何,但我尝试在我的代码中使用元素的z-index但没有成功.
我有一个div元素,其背景图像设置在css中.在div中,我有其他元素,比如div和img.我想让包含背景图像的主要div保持在最顶层,因为我希望背景图像显示在其他元素之上(此背景图像有一些圆角,我想在图像顶部显示在这个div).
示例HTML:
<div id="mainWrapperDivWithBGImage">
<div id="anotherDiv">
<!-- show this img behind the background image
of the #mainWrapperDivWithBGImage div -->
<img src="myLargeImage.jpg" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS示例:
/* How can I make the bg image of this div show on top of other elements contained
Is this even possible? */
#mainWrapperDivWithBGImage {
background: url("myImageWithRoundedCorners.jpg") no-repeat scroll 0 0 transparent;
height: 248px;
margin: 0;
overflow: hidden;
padding: 3px 0 0 3px;
width: 996px;
}
Run Code Online (Sandbox Code Playgroud) 我们站点中的一些UI功能突然无法正常工作,我收到错误消息:
jQuery未捕获的异常:语法错误,无法识别的表达式[tabindex ="something"]
这是我的代码:
var thumb_src = jQuery('a[name="thumb-image"] img[src*=' + sku + ']').attr('src');
jQuery( 'a[ tabindex=' + thumb_src + ']' ).prevAll().removeClass('selectedThumb');
jQuery( 'a[ tabindex=' + thumb_src + ']' ).addClass( 'selectedThumb' );
jQuery( 'a[ tabindex=' + thumb_src + ']' ).nextAll().removeClass('selectedThumb');
Run Code Online (Sandbox Code Playgroud)
它工作正常,直到jQuery升级到最新,我相信这是原因.我在上述陈述中做了什么违法行为吗?感谢您的任何意见或帮助!
任何人都有一些提示,如何在"新闻自动收报机"的方式从右到左水平地在div内滚动文本而不必使用插件.以下是我正在尝试完成的示例(这是一个插件解决方案:http://www.maaki.com/scrollingText.html).
我在我的网站上使用Bootstrap,只是在某些页面内容中添加了手风琴折叠.
它工作正常,但我想保持至少一个面板始终打开.
目前,面板始终切换打开/关闭,请参见下面的示例:
http://twitter.github.com/bootstrap/javascript.html#collapse
有人找到了解决方法吗?
以下是Boostrap站点的代码,它类似于我当前的实现(使用数据属性初始化它):
<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
Collapsible Group Item #1
</a>
</div>
<div id="collapseOne" class="accordion-body collapse in">
<div class="accordion-inner">
Anim pariatur cliche...
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
Collapsible Group Item #2
</a>
</div>
<div id="collapseTwo" class="accordion-body collapse">
<div class="accordion-inner">
Anim pariatur cliche...
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要将所有https请求重定向到http,例如,如果有人访问https://www.example.com/another-page/,请访问http://www.example.com/another-page/
我现在在web.config中有以下重写规则,但它无法正常工作.它将https://www.example.com/another-page/重定向到https://www.example.com/,所以到了网站的根目录,但我希望重定向保留在同一个网址中将https重写为http.
<rule name="Redirect to HTTP" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{R:1}" pattern="^onepage/(.*)$" negate="true" />
<add input="{HTTPS}" pattern="^ON$" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>
Run Code Online (Sandbox Code Playgroud)
任何有关更改上述规则的帮助,以便它只将https更改为http,但保持访问的完整网址将非常感谢!
我有以下代码,如果菜单项url == current url,应该在菜单项中添加一个活动的css类:
$("#accordion a").each(function()
{
if (this.href.search(window.location.hostname) != -1)
{
$(this).addClass("active-sidebar-link");
}
});
Run Code Online (Sandbox Code Playgroud)
但是这会将类添加到所有菜单项中.有小费吗?
我有以下javascript和knockout js代码从xml文件返回三个值:
var populateCategories = function (myId, mySize) {
self.categoryOptions([]); //Empty the observable array
var myCategories = getCategories(myId);
var i = null;
for (i = 0; myCategories.length > i; i += 1) {
if (myCategories[i].ProductSize == mySize) {
self.categoryOptions.push({ "label": myCategories[i].Reference });
}
}
Run Code Online (Sandbox Code Playgroud)
返回值(myCategories [i] .Reference)是"最佳","更好"和"好".我需要将这些值排序为"Good","Better","Best".按字母顺序排序不起作用,因为它将返回"好","最佳","更好".
返回的数据没有我可以用来对它们进行排序的另一个键/字段,所以我需要以某种方式在for循环上手动执行此操作.
如何对数据进行排序,以便最终结果为"良好","更好","最佳"?
我为不同的文档类型构建了一个定价计算器,根据文档中的页数,质量和数量为您提供最终价格.
定价由服务生成,每个请求的数据作为JSON对象输出,而不是在计算器上使用.
到目前为止,一切都适用于Chrome或Firefox,但不适用于Safari或IE.我已经能够缩小质量单选按钮的问题.
问题是,当您使用"质量"单选按钮时,Safari中的定价总是不正确.似乎第一次单击单选按钮没有触发,你总是得到不正确的价格.
我在jsfiddle上建立了一个示例,说明如何重现问题:https://jsfiddle.net/IntricatePixels/f21dtr8j/
JSFiddle的例子应该包含所有细节,但如果有必要,我很乐意在这篇文章中提供更多信息.
<div class="form-group document-quality">
<label>Quality</label>
<fieldset data-role="controlgroup">
<div class="field-container" data-bind="foreach:categoryOptions, valueUpdate: 'afterkeydown', event: { change: onSubmit }" id="documentQuality">
<label class="btn btn-default document-quality-label" data-bind="css: { 'active': $parent.selectedCategoryValue() === value }"></label>
<div class="radio-container">
<label class="btn btn-default document-quality-label" data-bind="css: { 'active': $parent.selectedCategoryValue() === value }">
<input data-bind="attr: {value: value}, checked: $parent.selectedCategoryValue" id="uniqueQuestionName" name="uniqueQuestionName" type="radio">
</label>
</div>
<label class="btn btn-default document-quality-label" data-bind="css: { 'active': $parent.selectedCategoryValue() === value }"><span data-bind="text: label"></span></label>
</div>
</fieldset>
</div>
<div class="form-group quantity">
<label>Quantity</label> …
Run Code Online (Sandbox Code Playgroud) 更新:
标签悬停的拇指图像调用一个名为displayImage()的函数:
function displayImage(index, parent){
var images = document.getElementById(parent).getElementsByClassName("mainProductImage");
for(var i = 0; i < images.length; i++) {
var image = images[i];
if (image.className != 'mainProductImage') { continue }
if(i == index-1) {
// display main image
image.style.display="block";
// change selectedIndex of select list
jQuery("#mySelect").attr('selectedIndex', index-1);
jQuery('#mySelect').trigger('change', [ i ]);
}
else {
image.style.display="none";
}
}
}
Run Code Online (Sandbox Code Playgroud)
我意识到我没有很好地解释这个:)我有n个图像缩略图,当悬停时改变页面上的主要产品图像.缩略图悬停事件将触发()来选择列表在同一页上(与产品的n个下拉的地方,如果有3张图片,有选择列表上3个相应的产品项目).
根据帕特里克的建议,当一个人将鼠标悬停在缩略图上时,我将其添加到循环中:
jQuery('#mySelect').trigger('change', [ i ]); // now passing the i variable
Run Code Online (Sandbox Code Playgroud)
然后我补充说:
$('#mySelect').change( function( event, idx ) {
if( idx === 0 …
Run Code Online (Sandbox Code Playgroud) 我坚持这个,需要一些帮助.我知道这个的逻辑解决方案,但不知道如何将其转换为jQuery代码(这里是新手:)).任何建议或帮助非常感谢!
我需要将一个css类(活动类)添加到一个title属性等于变量值的元素中.所以,让我们说我的变量currentElement ='伟大的一天'.页面上还有一个标签元素,其标题属性为"大日",例如<a title='great day' href='#'>
.
使用jQuery我想:在DOM中找到一个标签,其中currentElement ==标签标题并添加css类.所以,理想情况下它应该找到一个标签并将css类添加到它.
我想出了类似的东西,但没有工作:
/* set currentElement var to the src attribute
value of an a tag on the page
this works */
var currentElement = $('#greatLink'] img[src*=' + test + ']').attr('src');
/* now find an a tag on the page that has
the same title attribute as var currentElement
this does not work */
$("a[title ='+currentElement+']").addClass('selectedThumb');
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
var buttonOne = $("#buttonOne");
var buttonTwo = $("#buttonTwo");
// opens an already initialized modal window
(buttonOne, buttonTwo).click(function()
{
modalBoxContainer.dialog("open");
});
Run Code Online (Sandbox Code Playgroud)
这不起作用.如果我使用元素,它将起作用,但不会与变量一起使用.
有任何想法吗?
我想要完成的内容类似于Stackoverflow上其他帖子的PHP解决方案,但是使用JavaScript:
我正在返回一个具有以下内容的对象:
$.get(uri, function (data) {
self.options = [];
$.each(data, function (index, item) {
self.options.push(item);
});
});
Run Code Online (Sandbox Code Playgroud)
self.options []看起来像:
Object 1:
Id: "1"
Name: "Bill"
Object 2:
Id: "2"
Name: "Sarah"
Object 3:
Id: "3"
Name: "Mike"
Run Code Online (Sandbox Code Playgroud)
我需要在数组对象中找到"Sarah"并将其移动到数组的第一项.我怎样才能做到这一点?*
jquery ×7
javascript ×3
css ×2
html ×2
knockout.js ×2
accordion ×1
ajax ×1
arrays ×1
click ×1
collapse ×1
iis ×1
jquery-ui ×1
web-config ×1
z-index ×1