我得到了错误的计算,函数没有从.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)我在下面有这个代码,它似乎不起作用:
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替换它时,它将加载文件。我不确定是什么问题。
这是我的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)