我已经使用了content属性很长一段时间了,今天我想尝试新的东西.而不是使用JS来显示图像工具提示,我想知道是否可以使用CSS动态地执行它.
所以我尝试过:
.TableLine:hover:after{
content: url("../Img/Photo/"attr(id)".jpg");
}
Run Code Online (Sandbox Code Playgroud)
其中attr(id)
应该返回的图片(字母数字)的ID这也是图象的名称.
它根本不起作用,它没有效果.我认为该块没有解析,因为向块添加边框或背景似乎也没有效果.
当我只使用attr(id)
单独的,没有url的东西,它完美的工作.当我用attr(id)
图片的真实名称替换它时,它也有效.
在网上搜索了一段时间后,我没有发现任何相关内容,所以我在这里.这是一个已知的错误还是我的错误?:)
我有一些表行
<tr class="b_row">
<td>
<div class="cpt">
<h2>
<a href="/ref/ref/1.html">example</a>
</h2>
</div>
</td>
</tr>
<!--more elements -->
<tr class="b_row">
<td>
<div class="cpt">
<h2>
<a href="/ref/two/23.html">example N</a>
</h2>
</div>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我需要在属性中获取超链接.我用这个脚本
function openAll()
{
$("tr.b_row").each(function(){
var a_href = $('div.cpt').find('h2 a').attr('href');
alert ("Href is: " + a_href);
}
Run Code Online (Sandbox Code Playgroud)
问题:变量a_href
总是/ ref/ref/1.html
我试图通过svg旋转图像transform
.这是我的代码:
<svg width="100" height="100">
<image id="trns" transform="rotate(90,50,50)" width="100" height="100" xlink:href="logo.png"/>
</svg>
Run Code Online (Sandbox Code Playgroud)
logo.png
当页面加载时,这会成功旋转90度.此外,当我90
在firbug的HTML选项卡中更改为其他数字时,旋转也会相应更改.但是当我尝试使用jQuery更改值时,没有任何反应:
$('#trns').attr('transform', 'rotate(60, 50,50)');
Run Code Online (Sandbox Code Playgroud)
萤火虫做什么我的attr
线不?
我正在通过jQuery制作一些Rocket启动效果.当我点击Rocket时,它将与另一个火箭图像交换,然后启动.当我单击"重置"链接时,Rocket必须重置起始位置,图像必须恢复.但是有两个问题.首先,"我的火箭图像不会恢复".第二 - 在它恢复到初始位置后,如果我再次点击Rocket,它就不会启动.你能看到并找到我的解决方案吗?
http://jsfiddle.net/thisizmonster/QQRsW/
$("#resetlink").click(function(){
clearInterval(timerRocket);
$("#wrapper").css('top', '250px');
$("#rocket").attr('src', 'http://www.kidostore.com/images/uploads/P-SAM-rocket-blk.jpg');
});
Run Code Online (Sandbox Code Playgroud)
你可以看到$("rocket").attr()行.
我遇到了一个奇怪的问题:我正在创建一个应用程序的样式,我设置:
<item name="android:spinnerStyle">@style/CustomSpinnerAppearance</item>
<item name="android:textViewStyle">@style/CustomTextViewAppearance</item>
<item name="android:buttonStyle">@style/CustomButton</item>
Run Code Online (Sandbox Code Playgroud)
现在我想设置:
<item name="android:switchStyle">@style/CustomSwitch</item>
Run Code Online (Sandbox Code Playgroud)
我得到了这个错误.
找不到与给定名称匹配的资源:attr'android:switchStyle'.
我已经在API-Lvl 14和15(ICS)中检查了attrs.xml,并且:
<attr name="switchStyle" format="reference" />
Run Code Online (Sandbox Code Playgroud)
为什么我不能为交换机小部件设置自定义样式,尽管attr位于attrs.xml中?
更重要的是:我需要做什么,为Switch小部件应用程序设置自定义样式?
两者之间的主要区别是什么
$(this).attr("name")
Run Code Online (Sandbox Code Playgroud)
和
this.name
Run Code Online (Sandbox Code Playgroud)
什么是技术解释?
我想通过给出属性名称来选择属性值(仅以...开头)例如,如果我们有html标签
<div class = "slide" data-confirmID = "46" confirmID = "54"/>
Run Code Online (Sandbox Code Playgroud)
我想从属性开始选择值 data-
在此先感谢您的帮助.
我已经通过使用data()而不是attr()解决了这个问题,但我仍然想知道这是否只是我,以及是什么导致它:
我正在使用jQuery 1.7.1和TinyMCE 3.5b3(jQuery包).没有其他JS库.
当单击链接时,此代码按预期输出"string"和锚标记的href.
$('a.page_item_delete').on('click', function(event){
event.preventDefault();
var $this = $(this);
console.log(typeof $this.attr('href'));
console.log($this.attr('href'));
});
Run Code Online (Sandbox Code Playgroud)
当我在页面上的某些textareas上激活TinyMCE时,它会输出"Object",当然,attr()会停止返回预期值.我通过以下方式激活TinyMCE:
$( 'textarea.tinymce')TinyMCE的(选择);
有没有其他人用TinyMCE经历过这种行为?是否存在已知错误或解决方法?为什么TinyMCE显然会影响页面上不相关的HTML元素?
所以这是我的问题:我创建了一个扩展的自定义组件.Button
这个按钮有一个名为的属性testAttr
.
<declare-styleable name="TestButton" parent="@android:style/Widget.Button">
<attr name="testAttr" format="reference|color"/>
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)
我想为这个组件创建一个默认样式,所以我添加了这个:
<declare-styleable name="TestTheme">
<attr name="testStyle" format="reference"/>
</declare-styleable>
<style name="Theme.AppTheme" parent="@android:style/Theme" >
<item name="testStyle">@style/test</item>
</style>
Run Code Online (Sandbox Code Playgroud)
问题是我想要同时使用android属性和我自己的属性,这是行不通的:
<style name="test" parent="@android:style/Widget.Button">
<item name="android:background">#FF0000</item>
<item name="testAttr">testText</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我在自定义组件中设置默认样式,如下所示:
public myButton(final Context context) {
this(context, null);
}
public myButton(final Context context, final AttributeSet attrs) {
this(context, attrs, R.styleable.TestTheme_testStyle);
}
public myButton(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
final TypedArray array = context.obtainStyledAttributes(
attrs,
R.styleable.TestButton,
defStyle,
R.style.testDefault);
final …
Run Code Online (Sandbox Code Playgroud) 我的HTML代码在这里
<i id="bgcolor" style="background-color: rgb(255, 146, 180)"></i>
Run Code Online (Sandbox Code Playgroud)
我想使用jquery attr获取背景颜色值
我试过的是吼叫
$("#bgcolor").mouseleave(function(){
var bodyColor = $(this).attr("style");
$("body").css(bodyColor);
});
Run Code Online (Sandbox Code Playgroud)
但是这个输出是
background-color: rgb(255, 146, 180);
Run Code Online (Sandbox Code Playgroud)
我把它添加到.css它将无法工作.我如何实现这一任务?