如何传递被点击的元素 - Jquery

时间:2015-07-07 09:33:37

标签: jquery

这是我的代码:

(function ($) {
    function App() {
        this.init();

    }
    App.prototype.findSideBarLink = function(){
        $('#sidebar .list a[href*="'+ $(this).attr("href") +'"]').click();
    };
    App.prototype.init = function () {
        $('.column-header a').click(this.findSideBarLink());
        $('.column .column__more').click(this.findSideBarLink());
    }
}

我想在findSideBarLink函数中读取被点击的元素。 $(这个)不起作用。有什么建议吗?

2 个答案:

答案 0 :(得分:2)

您需要将函数引用作为单击事件处理程序

传递
$zeus = new grocery_CRUD();
$zeus->set_theme('bootstrap');
// $zeus->set_language('romanian');

$zeus->set_table('programari');
$zeus->columns(array('id_client', 'id_sala', 'denumire', 'numar_persoane', 'observatii'));

$zeus->callback_column('id_sala',array($this,'_test_function'));

$cod = $zeus->render();

$this->_afiseaza_panou($cod);

public function _test_function($row, $value)
{
  return '0';
}

答案 1 :(得分:0)

试试这样:

var showAll = false;
    jQuery(document).ready(function () {
        jQuery('#vmap').vectorMap(
    {
        map: 'male_anatomy',
        backgroundColor: '#a5bfdd',
        borderColor: '#818181',
        borderOpacity: .50,
        borderWidth: 1,
        color: '#f4f3f0',
        enableZoom: true,
        hoverColor: '#c9dfaf',
        hoverOpacity: null,
        normalizeFunction: 'linear',
        scaleColors: ['#b6d6ff', '#005ace'],
        selectedColor: '#c9dfaf',
        selectedRegion: null,
        showTooltip: true,
        onRegionClick: function (element, code, region) {
            $('path').each(function () {
                if (showAll) {
                    $(this).show();
                } else {
                    $(this).hide();
                }
            });
            if (showAll) { showAll = false; } else { showAll = true; }

            var id = '#jqvmap1_' + code;
            $(id).show();
        }
    });
    });