小编And*_*kUp的帖子

在自定义JQuery中嵌套JQuery UI选项卡

我正在运行一个Wordpress主题(Slate),它附带了实现标签的短代码jquery.tabs.min.js.

使用他们的短代码我尝试嵌套选项卡,它不起作用,很可能是因为他们如何设计短代码,所以我创建了一些简单的jQuery和额外的HTML来制作嵌套选项卡区域,然后包含原始主题的jquery选项卡短代码.

一切都在工作,但是有一个问题让我感到困惑:当加载子标签时包含的标签少于前面的父标签子标签,那么子标签就会溢出,jQuery会获得子标签从上一组中,将它们附加到当前选项卡.

这里有一个工作的例子.请注意,"锻炼"区域中的"冬季运动活动"子选项卡也会加载到夜生活区域,而"游览"父项选项卡中的博物馆和旅游景点也会加载到"日历"父级选项卡中,该选项卡应仅包含1个子选项卡(蒙特利尔活动) ).

所以我有一些奇怪的溢出继续..
我的初学者jQuery代码控制父标签在下面.

$(function(){
    var subcat = $('.sub-categories'),
        subdivfirst = $('.sub-categories div:first'),
        subdiv = $('.sub-categories div'),
        cattitlefirst = $('.categories ul li:first'),
        cattitle = $('.categories ul li');

        subcat.children('div').hide();  
        subdivfirst.show();     
        cattitlefirst.addClass('active');


        $('.categories li a').click(function(){
            var $this = $(this);

            cattitle.removeClass('active');
            subcat.children('div').hide();

            $this.parent('li').addClass('active');

            var catLink = $this.attr('id');
            var showcat = $('div #sub-' + catLink);

            showcat
                .fadeIn(600)    
                .find('.panes').show()
        });
});
Run Code Online (Sandbox Code Playgroud)

然后,这些" .subcategoriesdiv"中的每一个都包含标准的jQueryUI选项卡.

我认为jQueryUI选项卡和我创建的额外自制选项卡之间肯定存在某种冲突,但我不确定如何跟踪它.任何帮助,提示或想法清理我的代码将不胜感激.

jquery nested jquery-ui jquery-ui-tabs

7
推荐指数
1
解决办法
1466
查看次数

将wc_get_product()与PHP变量一起用于产品ID

我正在为WooCommerce中的产品构建自定义目标网页,我希望在其他内容中获取产品价格,以便在目标网页上显示它们.

每个登录页面都有一些自定义字段,允许WP管理员添加内容,登录页面以及产品ID,然后将用于生成产品价格,结帐URL等.

我无法wc_get_product();使用我的自定义字段或内置的变量.它仅在我使用直接ID时有效.我认为我不了解变量如何在PHP中运行.这是我的代码.

<?php 

//Gets the course ID from the custom field entered by user
$courseID = the_field('course_id');

// This line is where the problem is...
$_product = wc_get_product('$courseID');

// If I replace the line above with this line
// $_product = wc_get_product('7217');
//  everything works great, but that does not let 
// each landing page function based on the custom fields where the user determines 
// the product ID they are selling on that landing page.


// …
Run Code Online (Sandbox Code Playgroud)

php wordpress product woocommerce advanced-custom-fields

6
推荐指数
2
解决办法
2万
查看次数

使用Javascript/jQUery在HTML中测量字符串长度

我正在尝试运行一些自定义脚本,以根据h4元素中字符串的长度添加样式类.基本上,如果h4足够长,它占用2行,我将要调整CSS,以便带有两行标题的h4也与具有单行标题的h4对齐.

一点JQuery返回所有标签的内容..

jQuery(document).ready(function($){
  $('div.post-content div.title-info h4 a').text(function(){
      console.log(this);
  });
});
Run Code Online (Sandbox Code Playgroud)

这返回..

<a href=?"http:?/?/?www.theaterunder30.com/?farewell-to-amazing-grace/?">?Farewell to Amazing Grace?</a>?
<a href=?"http:?/?/?www.theaterunder30.com/?details-announced-for-harry-potter-and-the-cursed-child/?">?Details Announced for “Harry Potter and the Cursed Child”?   </a>?
<a href=?"http:?/?/?www.theaterunder30.com/?another-blog-post/?">?Another Blog Post?</a>?
<a href=?"http:?/?/?www.theaterunder30.com/?arrested-development-quotes/?">?Arrested Development Quotes?</a>?
Run Code Online (Sandbox Code Playgroud)

哪个好.但这只是谜题的一部分.我需要能够仅在标签内对字符进行计数,然后使用类似.length的内容来确定它是否大于X个字符执行{...}

我不确定如何访问标签之间的文字?为了在它上面运行.length.我看过这篇文章,但老实说我无法弄清楚如何将它应用到我的情况中.任何帮助或指导都会很棒.

谢谢你的期待!

html javascript css jquery

0
推荐指数
1
解决办法
1244
查看次数