如何将li
的宽度应用于a
?这应该发生在调整大小。 所以a
总是有li
宽度。jquery调整大小适用父宽度
var parentWidth = $('ul li').parent().width();
var $window = $(window);
$window.resize(function resize() {
$('ul li').each(function() {
if ($(this).closest('a').length == 1) {
parentWidth = $(this).closest('a').css('width').replace('px', '');
}
});
}
化妆锚显示块,不需要宽度100%http://jsfiddle.net/JCVnY/4/ – Huangism
@Huangism感谢,但我想申请到锚用的li与jquery。 – user2505665
你可以随时在锚点上设置显示CSS的道具来阻止使用jquery :)也最接近的是用来查找当前元素的父母,找到孩子,使用.find()http://api.jquery.com/找到/ – Huangism