嗨,我想在javascript上调用一个函数,我编写了一个简单的javascript代码,该代码正在控制台中运行,但是我想在我的主要c#程序中调用该函数
例如我的js
public function renderNewsTicker($atts = array(), $content = null)
{
// Override default options with the shortcode options
$atts = array_change_key_case((array)$atts, CASE_LOWER);
$options = shortcode_atts($this->defaultOptions, $atts);
// Get the posts
$postOptions = array(
'numberposts' => $options['num_posts'],
'category' => 0,
'orderyby' => 'date',
'order' => 'DESC',
);
if (!empty($options['post_cat']))
{
$postOptions['category_name'] = $options['post_cat'];
}
$posts = get_posts($postOptions);
// Render the marquee
if ($options['show_label'] == 'true')
{
$content .= '<div class="pjnt-border" style="background-color: '.$options['label_bg_colour'].'; border-color: '.$options['label_bg_colour'].';">';
$content .= '<div class="pjnt-label" style="color: '.$options['label_text_colour'].'; font-size: '.$options['size'].';">'.$options['label_text'].'</div>';
}
$content .= '<div class="pjnt-box" style="background-color: '.$options['ticker_bg_colour'].';">';
$content .= '<div class="pjnt-content" data-speed="'.$options['speed'].'" style="font-size: '.$options['size'].';">';
if (count($posts) == 0)
{
$content .= $options['no_content_text'];
}
else
{
$isFirst = true;
foreach ($posts as $post)
{
if (!$isFirst)
{
$content .= '<span class="pjnt-spacer"></span>';
}
$content .= '<a target="'.$options['target'].'" href="'.get_permalink($post).'"><img class="sliderimagetop" src="http://178.128.240.218/images/2018/08/xidasheli-86x64.jpg" alt="Italian Trulli">';
if ($options['show_excerpt'] == 'true') {
$content .= ' - '.get_the_excerpt($post);
}
$content .= '</a>';
$isFirst = false;
}
}
$content .= '</div>'; // end content
$content .= '</div>'; // end marquee box
if ($options['show_label'] == 'true')
{
$content .= '</div>'; // end border container
}
return $content;
}
}
new PjNewsTicker();
}
我想
$("body").on('DOMSubtreeModified', ".my-class", function() {
alert('changed');
});
program.cs
$("body").on('DOMSubtreeModified', ".my-class", function() {
callc#function(myclass text);
});