سؤال

I have a jquery tablesorter script, and I am trying to add these two functions together. It seems like it would be simple, though unfortunately I have very little knowledge with javascript.

It will only work when I have one or the other in the , not like i have it below.

<script type="text/javascript">
$(document).ready(function(){
    $(function() {
        $("table").tablesorter({ sortList:[[0,0]]
    }); }); });
$(document).ready(function(){
         $("table").tablesorter({
            textExtraction:function(s){
            if($(s).find('img').length == 0) return $(s).text();
            return $(s).find('img').attr('alt');
            } 
      });
});
</script>
هل كانت مفيدة؟

المحلول

Try to do:

<script type="text/javascript">
$(document).ready(function () {
    $("table").tablesorter({
        sortList: [
            [0, 0]
        ],
        textExtraction: function (s) {
            if ($(s).find('img').length == 0) return $(s).text();
            return $(s).find('img').attr('alt');
        }
    });
});
</script>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top