小编Ran*_*ndy的帖子

jQuery函数不返回值

我得到了错误的计算,函数没有从.investment元素返回3个值,因此我将能够计算它们并将它们输出到.payout元素中.我在这做错了什么?

function investmentArray() {
  $('.investment').each(function() {
    var text = $(this).text().slice(0, -2);
    text = parseFloat(text.replace(/,/g, ''));
    text = Number(text);
    return text;
  });
};

function payoutCalc() {
  var i = investmentArray();
  return i * 1.8;
}

var payoutArray = function() {
  var el = $('.payout');
  el.each(function() {
    var result = Number(payoutCalc()).toFixed(2);
    $(this).html(result + " $");
  });
}
payoutArray();
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table>
  <tr>
    <th>Investment</th>
    <th>Payout</th>
  </tr>
  <tr>
    <td class="investment">1,937.00 $</td>
    <td class="investment">285.00 $</td>
    <td class="investment">1,926.00 $</td>
  </tr>
  <tr>
    <td …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

4
推荐指数
1
解决办法
174
查看次数

WordPress admin_enqueue_scripts 不工作

我在下面有这个代码,它似乎不起作用:

function load_custom_wp_admin_style() {
    wp_register_style( 'custom_wp_admin_css', get_stylesheet_directory_uri() . '/admin-style.css', false, '1.0.0' );
    wp_enqueue_style( 'custom_wp_admin_css' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
Run Code Online (Sandbox Code Playgroud)

但是当我用wp_enqueue_scripts而不是admin_enqueue_scripts替换它时,它将加载文件。我不确定是什么问题。

wordpress wordpress-theming

3
推荐指数
1
解决办法
4076
查看次数

jQuery - 如何在点击时检测视频栏播放按钮,而不是视频本身

这是我的HTML代码:

<div class="video_container">
<button class="play">Play</button>              
<video controls poster="image.png">
<source src="video.mp4" />
<img alt="Img" src="image.png" title="Some Image" /></video>
</div>
Run Code Online (Sandbox Code Playgroud)

jQuery的:

jQuery(document).ready(function ($) {
  // Center Play Button Onclick 
  $('button.play').click(function () {
    var play_button = $(this);
    var video = $(this).parent().find('video').get(0);
       if (video.paused) {
          video.play();
          play_button.hide();         
       } else {
          video.pause();
          play_button.show();
       }
       return false;
    });

  // Video Onclick 
  $('video').click(function () {
    var play_button = $(this).parent().find('button.play');
    var video = $(this).get(0);
       if (video.paused ) {
          video.play();
          play_button.hide();   
       } else {
          video.pause();
          play_button.show();
       }
       return false; …
Run Code Online (Sandbox Code Playgroud)

html jquery html5-video

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